Forum Discussion
lndayong
May 30, 2022Copper Contributor
Changing automatically several links on several files in Excel
Hello Everyone, I am trying to update a bulk of Excel files and each has about 30 links to file from the previous quarter, say "122021". How do I update this automatically, each quarter (first on o...
HansVogelaar
May 30, 2022MVP
Perhaps a macro. It assumes that the workbooks to be updated are in a single folder, with no other workbooks.
Sub MultiUpdate()
' Path must end in \
Const strPath = "C:\Excel\"
' Change as needed
Const strFrom = "122021"
Const strTo = "032022"
Dim strFile As String
Dim wbk As Workbook
Dim wsh As Worksheet
Application.ScreenUpdating = False
strFile = Dir(strPath & "*.xls*")
Do While strFile <> ""
Set wbk = Workbooks.Open(Filename:=strPath & strFile, UpdateLinks:=False)
For Each wsh In wbk.Worksheets
wsh.Cells.Replace What:=strFrom, Replacement:=strTo, LookAt:=xlPart
Next wsh
wbk.Close SaveChanges:=True
strFile = Dir
Loop
Application.ScreenUpdating = True
End Sub
- lndayongMay 30, 2022Copper Contributor
Thank you for your response. I however tried this and it did not work for me. Maybe I didnt explain properly my problem, apologies.
In each file, I have several links pointing to diffferent files with a part of the name being 122021. These file have the same structure as the file with name 032022. As I am trying to roll forward the 032022 file to 062022, I need to change all the links with name 122021 to 032022.
This roll forward to be done for about 15 files of similar structure (with differing links)
Please if you have any proposals, it will be much appreciated.
- HansVogelaarMay 30, 2022MVP
Are the filenames part of cell formulas?
- lndayongMay 30, 2022Copper Contributor
Yes they are.