Referencing worksheet name using code name
I would like to be able to reference several worksheets (the number and code name determined at run time) using their code name such as sheet5. How do I do this with code to account for the fact that this code name needs to be a variable. Thus I need to hide various sheets but their sheet name and sheet position is variable; the only thing that I know for sure is their code name. Thus I am after something like this.
for each sheet
(sheet5 as a variable).visible=false
next sheet
How do I achieve this?:hi:
Take a look at this example
Hi Salvo:
I am not quite sure whether I follow you, but may be this code example will point you in the right direction:
[vba]
Dim sh() As Worksheet
ReDim sh(0)
Set sh(0) = Sheets("Sheet1")
ReDim Preserve sh(1)
Set sh(1) = Sheets("Sheet2")
Dim s As Variant
For Each s In sh
Debug.Print s.Name
Next s
[/vba]