Hello,
My first on this forum!
I'm quite new to VBA. Having some trouble trying to copy sheets. Not quite sure what's going wrong here:
I have a template workbook (checker.xlsm) which has 2 sheets (FormatControl, ErrorControl), both of which I want to copy to an Excel workbook that the user selects.
So far I have the code below:
Unfortunately I get run time error '9' - subscript out of range in the last part.
Where am I going wrong?
Help greatly appreciated!
My first on this forum!
I'm quite new to VBA. Having some trouble trying to copy sheets. Not quite sure what's going wrong here:
I have a template workbook (checker.xlsm) which has 2 sheets (FormatControl, ErrorControl), both of which I want to copy to an Excel workbook that the user selects.
So far I have the code below:
Code:
Sub MoveSheets()
targetWB = Application.GetOpenFilename()
Workbooks.Open (targetWB)
Windows("checker.xlsm").Activate
Sheets(Array("ErrorControl", "FormatControl")).Select
Sheets("FormatControl").Activate
Sheets(Array("ErrorControl", "FormatControl")).Copy Before:=Workbooks( _
targetWB).Sheets(1)
End Sub
Unfortunately I get run time error '9' - subscript out of range in the last part.
Where am I going wrong?
Help greatly appreciated!