How to remove external links with BASIC macro in calc spreadsheet?

Of course, we are discussing the case when both documents are open in LO.
In Excel, when inserting a row into the range of the first document referenced by the second document, the address will be adjusted.
In Calc, in a similar case, the reference does not change.
In such cases, it is recommended to use (document or sheet) named ranges.