N
Norman Goldsmith
I know that the statement: Sheets(Array("Name1","Name2", "NameN")).Select
will select all of the sheets that are explicitly listed within Array(). For
my purposes, the number of sheets will always be different and their names
will always be different. I want to be able to select all but the first
sheet.
I created an Array I called SheetArray() with the names (or sheet numbers if
needed) of the sheets that I want to select. The variant SheetArray() was
ReDimed (that's a verb?) to hold the names.
What I can't figure out is the syntax that allows me to use the populated
SheetArray() within the Select statement. The simplistic
Sheets(SheetArray()).Select returns error 9, subscript out of range.
------------------------------------------------------
Code fragment:
Dim SheetKtr As Long
Dim SheetArray() As Variant
SheetKtr = ActiveWorkbook.Sheets.Count
ReDim SheetArray(SheetKtr - 1) '1 less than total number of
sheets
For I = 0 To SheetKtr - 2 'assuming zero based
array
SheetArray(I) = Sheets(I + 2).Name 'name of sheet #2 and beyond
Next I
Sheets(Array(?)).Select
Please help.
Excel 2003, SP3.
Norm
will select all of the sheets that are explicitly listed within Array(). For
my purposes, the number of sheets will always be different and their names
will always be different. I want to be able to select all but the first
sheet.
I created an Array I called SheetArray() with the names (or sheet numbers if
needed) of the sheets that I want to select. The variant SheetArray() was
ReDimed (that's a verb?) to hold the names.
What I can't figure out is the syntax that allows me to use the populated
SheetArray() within the Select statement. The simplistic
Sheets(SheetArray()).Select returns error 9, subscript out of range.
------------------------------------------------------
Code fragment:
Dim SheetKtr As Long
Dim SheetArray() As Variant
SheetKtr = ActiveWorkbook.Sheets.Count
ReDim SheetArray(SheetKtr - 1) '1 less than total number of
sheets
For I = 0 To SheetKtr - 2 'assuming zero based
array
SheetArray(I) = Sheets(I + 2).Name 'name of sheet #2 and beyond
Next I
Sheets(Array(?)).Select
Please help.
Excel 2003, SP3.
Norm