Hi everyone! Just ran into this issue and not sure how to get around it. So the macro is looping through all the excel files in a folder, open each one and make changes. However, a few of the files have different tab names, therefore I want to give the user a notification regarding which files are different so that they can change them later.
The problem is the code keeps running after activeworkbook.close and pop up the msgbox "Please check names of the external tabs..." If I put "Next" before the ErrorHandler, it will not go to the next file... Let me know if you know how to solve the issue and many thanks in advance!!
The problem is the code keeps running after activeworkbook.close and pop up the msgbox "Please check names of the external tabs..." If I put "Next" before the ErrorHandler, it will not go to the next file... Let me know if you know how to solve the issue and many thanks in advance!!
VBA Code:
Set fso = CreateObject("scripting.filesystemobject")
Set ff = fso.getfolder(folderpath)
For Each file In ff.Files
Workbooks.Open file
On Error GoTo ErrorHandler
.
.
.
ActiveWorkbook.Save
ActiveWorkbook.Close ' for good files
ErrorHandler:
MsgBox "Please check names of the external tabs..."
ActiveWorkbook.Close SaveChanges:=False 'for bad files
Next
End If