Hello all,
I've got a macro that copy-pastes project data from two different sheets into a new sheet, saves this third sheet as a new file, and loops through that same process with the next batch of data (i.e. the next project).
The macro works fine...for 5 files, then it gives a 1004 warning about protected workbooks (see screenshot).
This surprised me because a) the macro itself sets a password on the newly created file AFTER doing all the copy-pasting, and b) why would the macro run fine for the first 5 files, and then suddenly stop?
Before posting the entire code, I wondered if there's a generic answer / thing I might have overlooked that causes a macro to run into this error midway through the iteration.
Any thoughts are much appreciated.
Best,
Paul
EDIT:
It may be useful to know that the debugger points me to the line
wbkOut.Close SaveChanges:=True
I've got a macro that copy-pastes project data from two different sheets into a new sheet, saves this third sheet as a new file, and loops through that same process with the next batch of data (i.e. the next project).
The macro works fine...for 5 files, then it gives a 1004 warning about protected workbooks (see screenshot).
This surprised me because a) the macro itself sets a password on the newly created file AFTER doing all the copy-pasting, and b) why would the macro run fine for the first 5 files, and then suddenly stop?
Before posting the entire code, I wondered if there's a generic answer / thing I might have overlooked that causes a macro to run into this error midway through the iteration.
Any thoughts are much appreciated.
Best,
Paul
EDIT:
It may be useful to know that the debugger points me to the line
wbkOut.Close SaveChanges:=True
Last edited by a moderator: