Code in macro to return to previously active sheet
Posted by Dwight on August 27, 2001 1:47 PM
I tried to record a macro to revise a large number of similarly structured spreadsheets. At one point in the macro, I wish to open another spreadsheet (named "Aladin's 30-60-90 Solution"), copy some fairly complex formulas from it, and paste them in the sheet I am trying to modify. When I run the macro, I get a "Run time error '9', subscript out of range" message. A fragment of the macro follows. I guess what I want to do is replace the code that says to activate "Dwight Hamilton Test ...." (the sheet I recorded from) with something that will instead return to the sheet which was active before activating the "Aladin's Solution ..." spreadsheet.
Any ideas?
Range("B25").Select
Windows("Aladin's 30-60-90 Solution.xls").Activate
Range("B25:F28").Select
Selection.Copy
Windows("Dwight Hamilton Test 4 30-60 Cleanup.xls").Activate
ActiveSheet.Paste