Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Repeating VBA operations
I have several hundred lines of code that look like:
Sheets("First").Select [LOTS OF CODE HERE] End of code If I want to repeat all of the same steps on two other sheets, do I have to copy and paste the code twice under the names of the two different sheets or is there a command I can use to repeat all of the code on different sheets? Thanks (P.S. I am a total novice, so the easier the solution the better.) |
#2
|
|||
|
|||
First step is declare a variable to hold the sheet names: I use one
called SheetName: dim SheetName Then set up a FOR...NEXT loop to repeat your code for each worksheet: For each SheetName in Sheets Sheets(SheetName).Select [Lots of code here] Next SheetName |
#3
|
|||
|
|||
thanks again!
"Dave O" wrote: First step is declare a variable to hold the sheet names: I use one called SheetName: dim SheetName Then set up a FOR...NEXT loop to repeat your code for each worksheet: For each SheetName in Sheets Sheets(SheetName).Select [Lots of code here] Next SheetName |
#4
|
|||
|
|||
Glad to help!
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
repeating formulas by the same row or colum increment as the last. | Excel Discussion (Misc queries) | |||
repeating formulas by the same row or colum increment as the last. | Excel Discussion (Misc queries) | |||
Header - stop repeating on every page! | Excel Discussion (Misc queries) | |||
reference a repeating cell in a formula | Excel Worksheet Functions | |||
Repeating formula in Excel | Excel Discussion (Misc queries) |