View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Choose several sheets in VBA

Hi Jonnson.

Try:

ActiveWorkbook.Sheets(Array("Sheet4", "Sheet5", "Sheet6", _
"Sheet7", "Sheet8", "Sheet9")).Select

---
Regards,
Norman



"Jonsson" wrote in message
...
Hi,
I'm trying to learn VBA and I need some help with this:
The code below makes the sheets 4 and more to be selected up to the last
sheet in the workbook.
Can anyone give me help to create a code that select sheet 4 to 9 in a
workbook with more than 9 sheets.
I mean, how to get that array in the workbook?

Dim sheetArray() As Integer
Dim firstSheet As Integer, sheetCount As Integer, x As Integer
firstSheet = 4
sheetCount = ThisWorkbook.WorkSheets.Count - firstSheet
ReDim sheetArray(sheetCount)
For x = 0 To sheetCount
sheetArray(x) = firstSheet + x
Next x
ThisWorkbook.WorkSheets(sheetArray).Select


Thanks in advance!

//Thomas