Fastest way to select a sheet codename
Sure, I'll try to elaborate on my "Do stuff" code.
Basically, if the "ws.CodeName" is between Sheet1 and Sheet25,
then the "Do stuff" is as follows:
Set pWS = Sheet51
Then, if "ws.CodeName" is between Sheet26 and Sheet50, then
the "Do stuff" is:
Set pWS = Sheet52
It would be nice if I could use the "Select Case" statement as
follows (but I don't think it will work):
Select Case ws.CodeName
Case "Sheet1" to "Sheet25":
Set pWS = Sheet51
Case "Sheet26" to "Sheet50":
Set pWS = Sheet52
End Select
"Rick Rothstein" wrote in message
...
Whether you can shorten that up or not is highly dependent on what each of
the "Do stuff" are. If the code for them is all the same except for the
CodeName reference, then you can shorten this up dramatically... if they
are differences other than in the CodeName, then it depends on what those
differences are as to whether you can simplify the code or not... if there
is some serial regularity about numbers that appear in them, then maybe a
mathematical expression can be used to simplify the loops... but if the
"Do stuff" is wildly different from each other, then you have to specify
each one separately. We would have to see the "Do stuff" to decide.
--
Rick (MVP - Excel)
|