(Solved) – Applying master workbook VBA to 1000 files is not working


Following the instructions on this older stackflow question, I tried to run my macro with the following code:

Sub ay1()
Dim fileName, Pathname As String
Dim wb As Workbook
Pathname = "https://stackoverflow.com/Users/ayy/Downloads/Folder1/STATS1/"
fileName = Dir(Pathname & "*.csv")
Do While fileName <> ""
    Set wb = Workbooks.Open(Pathname & fileName)
    DoWork wb
    wb.Close SaveChanges:=True
    fileName = Dir()
End Sub

Sub DoWork(wb As Workbook)

With wb

            ActiveSheet.Range("$A$1:$C$191").AutoFilter Field:=3, Criteria1:="="
            ActiveSheet.Range("$A$1:$C$96").AutoFilter Field:=3

    End With
End Sub

I tried to save this in a “master workbook” that is macro-enabled in the same directory where all my .csv files are located. Then I clicked run macro and selected ay1.

For some reason this is not running on any of my files and I’m wondering why this may be the case. I’m not getting any errors, and nothing is done to my files either.

Any help or guidance would be greatly appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *