Renaming excel file without breaking links to other excel files

Peter Davison

Active Member
Joined
Jun 4, 2020
Messages
435
Office Version
  1. 365
Platform
  1. Windows
Hi,
I have a master excel file that I want to rename, however I have four other files with many thousands of formulas that relate back to my master file.
Is there a way I can rename my master file without affecting all the formulas in my other four files?
Any help would be appreciated.
Thanks
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
You could try something like this which is untested, this does rely on both files existing though so preobably need s tweaking
VBA Code:
Sub tst()
Dim ws As Worksheet

strk = "='C:\Documents and Settings\username\filename.xlsm'!"
strk2 = "='C:\Documents and Settings\username\newfilename.xlsm'!"
For Each ws In ActiveWorkbook.Worksheets
    
    row_min = ws.UsedRange.Row
    row_max = row_min + ws.UsedRange.Rows.Count - 1
    col_min = ws.UsedRange.Column
    col_max = col_min + ws.UsedRange.Columns.Count - 1

inarr = Range(Cells(row_min, col_min), Cells(row_max, col_max)).Formula
ilim = UBound(inarr, 1)
jlim = UBound(inarr, 2)

For i = 1 To ilim
For j = 1 To jlim
   forstr = CStr(inarr(i, j))
     If forstr <> "" Then
        MMn = InStr(forstr, strk)
        If MMn > 0 Then
         inarr(i, j) = Replace(forstr, strk, strk1)
        End If
     End If
 Next j
 Next i
Range(Cells(row_min, col_min), Cells(row_max, col_max)).Formula = inarr
Next ws

End Sub
 
Upvote 0
Hi,
I have a master excel file that I want to rename, however I have four other files with many thousands of formulas that relate back to my master file.
Is there a way I can rename my master file without affecting all the formulas in my other four files?
Any help would be appreciated.
Thanks
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top