Select an array of worksheets VBA

  • Thread starter Thread starter Jamuck
  • Start date Start date
J

Jamuck

I am trying to write a macro that will select an array of worksheets.
The number of worksheets may vary from book to book so I tried usin
the following:
Sheets(Array("Sheet (1)", Sheets(Sheets.Count))).Select

but this doesn't work. Can anyone help me out please:confused
 
Are you trying to select all the sheets?

sheets.select

maybe????
 
Sheets(Array(Sheets(1).name, Sheets(Sheets.Count).name)).Select

Will select 1st and last worksheets

HTH
 
Thanks for that. Is it possible to select a range of worksheets ie fro
say the second sheet to the last
 
One way:

Dim iCtr As Long
With ActiveWorkbook
For iCtr = 2 To .Sheets.Count
.Sheets(iCtr).Select Replace:=CBool(iCtr = 2)
Next iCtr
End With
 
Thanks Dave but I pasted in the code you gave and it returned an error.
I understand all that you wrote except for the 'replace' statement which
I guess is the key to it.
 
Replace will specify whether you want the sheet selected by itself or added to
the group of selected sheets.

If it didn't work for you, you'll have to post the code you used and the actual
error you received.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top