0
votes

What I really need is a way to select multiple worksheets in a workbook based on index and/or location in the tab lineup. However, even the simplest select-by-index code is returning this frustrating error.

Here's the simplest code that still returns the error:

Sub testselect()
Worksheets(1).Select
End Sub

And here's the gist of what I'd like to make work, but probably won't even after I solve this frustrating error:

Sub testselect2()
Worksheets(Array(Worksheets(1), Worksheets(2), Worksheets(3), Worksheets(4))).Select
End Sub
1
Have you tried recording a macro and comparing the generated code with what you have? - Mathieu Guindon
Make sure the worksheet is not Hidden or protected from being Selected - Gary's Student
Worksheets(Array(1, 2, 3, 4)).Select? - David Zemens

1 Answers

0
votes

You're entering the Array wrong:

Sub testselect2()
Sheets(Array(1, 2, 3, 4)).Select
End Sub