I am hoping that @TimWilliams sees this. About 2 years ago he replied to a question regarding changing a string in multiple spreadsheets with the below VBA. I am trying to do the same, but not change a string in worksheets, I am trying to change a string in the VBA modules of the different spreadsheets (to change the directory path as we are moving from a mapped drive to the cloud). I was wondering if the below can be adjusted to do that?
Thanks
Sub ReplaceStringInExcelFiles()
Dim MyFile As String
Dim FilePath As String
Dim orig As String
Dim news As String
Dim wb As Workbook, ws As Worksheet
orig = "cow"
news = "dog"
FilePath = "C:\myDir\"
MyFile = Dir(FilePath & "*.xls*")
Do While Len(MyFile) > 0
Set wb = Workbooks.Open(FilePath & MyFile) '<< assign the workbook to wb
'Loop over the worksheets
'Note: no need to activate/select
For Each ws In wb.Worksheets
ws.UsedRange.Cells.Replace what:=orig, _
Replacement:=news, _
lookAt:=xlPart, SearchOrder:=xlByRows, _
MatchCase:=False
Next ws
ActiveWorkbook.Close savechanges:=True
MyFile = Dir
Loop
End Sub
Haven't tried anything as no idea