Code:worksheets(array(1,2,3,4)).select
Try ..Another one, how can I select first (n-1) sheets? For example, if I have 5 sheets in total. I want to select first 4. If I have 6 sheets in total, I want to select first 5.
Sub SelectAllButLast()
Dim i As Long
Sheets(1).Select
For i = 2 To Sheets.Count - 1
Sheets(i).Select Replace:=False
Next i
End Sub
Thank you VBA Geek! Another one, how can I select first (n-1) sheets? For example, if I have 5 sheets in total. I want to select first 4. If I have 6 sheets in total, I want to select first 5. Can I use something like Sheets.Count?
Thank you!
Worksheets(Evaluate("TRANSPOSE(ROW(1:" & ThisWorkbook.Worksheets.Count - 1 & "))")).Select
you can do it as Peter suggested, and also like this:Code:Worksheets(Evaluate("TRANSPOSE(ROW(1:" & ThisWorkbook.Worksheets.Count - 1 & "))")).Select