JoetheSousChef
Technical User
I have three open workbooks. I want to cut and paste different pieces of data from Book1 to Book3. The macro recorder writes
as the code to advance to the next workbook in response to my Ctrl-Tab sequence on the keyboard.
That's fine but it requires that the workbooks be opened in the same sequence each time I run the macro.
I thought I could use Activate to specify the workbook I wanted to be active in; as in
which I copied directly from the example in VBA Help. This line, however, stops the program with a report of "run time error 9" "subscript out of range".
Would appreciate any help for a novice programmer on two points.
.Are there other (simple) ways to specify
which workbook is the active workbook to copy from/
paste to?
.Why does the second line of code stop the macro
running?
Thanks in advance for your time.
Code:
ActiveWindow.ActivateNext
as the code to advance to the next workbook in response to my Ctrl-Tab sequence on the keyboard.
That's fine but it requires that the workbooks be opened in the same sequence each time I run the macro.
I thought I could use Activate to specify the workbook I wanted to be active in; as in
Code:
Workbooks("BOOK1").Activate
which I copied directly from the example in VBA Help. This line, however, stops the program with a report of "run time error 9" "subscript out of range".
Would appreciate any help for a novice programmer on two points.
.Are there other (simple) ways to specify
which workbook is the active workbook to copy from/
paste to?
.Why does the second line of code stop the macro
running?
Thanks in advance for your time.