Hi I am trying to test this on a folder containing 5 files, it opens all files but it only completes the action on 1 file then seems to freeze excel completely.
I am new to the world of Macros and lifted the code from a website, so I am hoping this will be a good way to get an answer.
Have I got the "Loop" in the wrong place, something else wrong, or is it likely to be a problem with Excel 2019? Thanks in advance
I am new to the world of Macros and lifted the code from a website, so I am hoping this will be a good way to get an answer.
Have I got the "Loop" in the wrong place, something else wrong, or is it likely to be a problem with Excel 2019? Thanks in advance
Code:
Sub ProcessFiles()
Dim Filename, Pathname As String
Dim wb As Workbook
Pathname = ActiveWorkbook.Path & "R:\Testing\Test col shift loop\"
Filename = Dir(Pathname & "*.xlsm")
Do While Filename <> ""
Set wb = Workbooks.Open(Pathname & Filename)
DoWork wb
wb.Close SaveChanges:=True
Filename = Dir()
Loop
End Sub
Sub DoWork(wb As Workbook)
With wb
Sheets("TF ROC").Select
Range("EL2:EN2").Select
Selection.Replace What:="G", Replacement:="F", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End With
End Sub