I know this question must've been asked before, but I can't find the answer anywhere...
In any event, I have 50 sheets. I have given them names in excel different than "Sheet1" "Sheet2" through "Sheet50"... they are called "alpha", "beta", "gamma" etc...
under the VB editor, under VBA project, under "Microsoft Excel Objects", I have the following:
Sheet01 (alpha)
Sheet02 (beta)
Sheet03 (gamma)
etc..
Note that I've renamed the Sheet as sheet01 to allow for the objects to be ordered...
to loop, I do the following:
I want to set the cell A1 to 1 in sheets 15 through 25 only:
For i = 15 to 25
sheets(i).Range("A1") = 1
Next
but in the event that a user takes the sheet "alpha" (which is sheet(1)), and puts in between sheets 15 and 25, the code will no longer work.
I might've confused you by all the above, so if you need clarification, please let me know.
I can sum this up by the following request:
I would like a loop that goes through a number of sheets without being impacted by the arrangement of the sheets in excel.
Thanks,
hilss
In any event, I have 50 sheets. I have given them names in excel different than "Sheet1" "Sheet2" through "Sheet50"... they are called "alpha", "beta", "gamma" etc...
under the VB editor, under VBA project, under "Microsoft Excel Objects", I have the following:
Sheet01 (alpha)
Sheet02 (beta)
Sheet03 (gamma)
etc..
Note that I've renamed the Sheet as sheet01 to allow for the objects to be ordered...
to loop, I do the following:
I want to set the cell A1 to 1 in sheets 15 through 25 only:
For i = 15 to 25
sheets(i).Range("A1") = 1
Next
but in the event that a user takes the sheet "alpha" (which is sheet(1)), and puts in between sheets 15 and 25, the code will no longer work.
I might've confused you by all the above, so if you need clarification, please let me know.
I can sum this up by the following request:
I would like a loop that goes through a number of sheets without being impacted by the arrangement of the sheets in excel.
Thanks,
hilss