Whenever I make changes across standard files, I like to take two copies of the sheets I'm changing to (1) preserve the original values, and (2) compare to the changed sheet (Sheet1!A1 - Sheet2!A1) to make sure there are no unexpected differences. Once I'm comfortable with the updates, I then delete the duplicate sheets.
The code that loops through the files and makes the changes works fine, it's the code that copies the sheets that I can't figure out. Each file has two sheets, the sheet names are all different.
This is my code. It's the Sheets(Array(Sheet... lines that are giving me error code 424, object required.
Sub PleaseWork()
Dim wb As Workbook
For Each wb In Application.Workbooks
If wb.Name <> "PERSONAL.XLSB" Then
Debug.Print wb.Name
wb.Activate
Sheets(Array(Sheet1.Name, Sheet2.Name)).Copy Before:=Sheets(1)
Sheets(Array(Sheet1.Name, Sheet2.Name)).Copy Before:=Sheets(1)
Sheets(1).UsedRange.SpecialCells(xlCellTypeFormulas, 23).FormulaR1C1 = _
"=ROUND('" & Sheets(3).Name & "'!RC-'" & Sheets(5).Name & "'!RC,4)"
Sheets(2).UsedRange.SpecialCells(xlCellTypeFormulas, 23).FormulaR1C1 = _
"=ROUND('" & Sheets(4).Name & "'!RC-'" & Sheets(6).Name & "'!RC,4)"
Sheet2.Activate
Columns("J:J").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("I16:I18,AD2:AG14").ClearContents
Range("N3,N21,X3,X21,AC21,AC3").Value = "Cash Flows"
End If
Next wb
MsgBox "All Finished!"
End Sub
I've tried variations using ActiveWorkbook, ThisWorkbook, Application.ActiveWorkbook, Application.ThisWorkbook, etc. but nothing works. I'd really appreciate some help!
My code is stored in my Personal.xlsb workbook.
Thanks in advance.