I have a list of workbooks that follow the same template, and all have a macro 'beforesave' event, which basically creates a save-log in on of the sheets, listing the time and user id from whoever is saving the workbook.
So sometimes I need to change a formula in all workbooks, and since it takes around a minute to close and save each of them manually, I created a macro that opens all of them changes what I need changed, and closes saving them. That would save me some significant amount of time, as on total this process ends up taking around 30 mins of my time, and a lot of boredom.
Problem is: when the macro tries to close and save the workbook, the 'beforesave' event doesn't run properly and as a result the workbook doesn't save and close with the macro. For some reason, the event seems to be skipped in the macro...
To solve that I want to run this macro to make all the changes in all workbooks, skipping the beforesave event (if necessary) and actually saving and close them at the end.
Help please?
Tried running the macro line by line, and when it gets to the event part, it calls it, but for some reason it stays in the same sheet instead of going to the log sheet, and writes the log info in the wrong sheet as a result. In any case, running line by line won't obviously work for me as it's basically the same as doing the process myself, manually.
Sub DoStuff()
Dim Row As Integer
Dim Col As Integer
Dim wbCopy As Workbook
Dim wbPaste As Workbook
Dim wbBP As Workbook
For Col = 4 To 4
ThisWorkbook.Activate
Set wbBP = Workbooks.Open(Cells(1, Col), False)
ThisWorkbook.Activate
Set wbCopy = Workbooks.Open(Cells(2, Col), False, True)
For Row = 3 To 19
ThisWorkbook.Activate
SetAttr Cells(Row, Col), vbNormal
Set wbPaste = Workbooks.Open(Cells(Row, Col), False)
wbCopy.Activate
Sheets("Base").Activate
Range("A7:EQ500").AutoFilter
wbPaste.Activate
Sheets("Base").Activate
Range("A7:EQ500").AutoFilter
wbCopy.Activate
Sheets("Base").Activate
Range("AL8:AS8").Copy
wbPaste.Activate
Sheets("Base").Activate
Range("AL8:AS" & Cells(Rows.Count, 1).End(xlUp).Row).PasteSpecial xlPasteFormulas
Application.CutCopyMode = False
wbPaste.Close True
ThisWorkbook.Activate
SetAttr Cells(Row, Col), vbReadOnly
Next Row
wbCopy.Close False
wbBP.Close False
Next Col
End Sub
Running the macro to do the changes I need, and having all workbooks involved saved and closed properly.