I am trying to create a VB Macro to replace a string found in multiple excel files in a directory. My code is below but it is not working and I am not sure what I need to do to fix it.
Any suggestions ?
Sub ReplaceStringInExcelFiles()
Dim MyFile As String
Dim FilePath As String
Dim orig As String
Dim news As String
orig = "cow"
news = "dog"
FilePath = "C:\myDir\"
MyFile = Dir(FilePath)
Do While Len(MyFile) > 0
Workbooks.Open (FilePath & MyFile)
For q = 1 To Application.Worksheets.Count
Worksheets(q).Activate
Sheets("Sheet1").Cells.Replace what:=Original_String, Replacement:=New_Replacement_String, lookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
Next q
ActiveWorkbook.Save
ActiveWorkbook.Close
MyFile = Dir
Loop
End Sub