Select a range of sheets

helgeroe

New Member
Joined
Dec 16, 2008
Messages
37
Hi
I have a macro that creates a varied number of sheets (that will all be placed to the right of the old sheets) and want to select the new sheets.

Anbody have an easy way I can select the new range of sheets?

Sheets(x+1) -> Sheets(n+x)

...where: x= amount of old sheets
n= amount of new sheets

Thanks.

Helge
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
There are various ways - for example:
Code:
   Dim blnNew As Boolean
   Dim x As Long
   blnNew = True
   ' select sheets from 3 on
   For x = 3 To Sheets.Count
      Sheets(x).Select blnNew
      blnNew = False
   Next x
or you could create an array of sheet names and then use that with the Sheets collection.
 
Upvote 0
There are various ways - for example:
Code:
   Dim blnNew As Boolean
   Dim x As Long
   blnNew = True
   ' select sheets from 3 on
   For x = 3 To Sheets.Count
      Sheets(x).Select blnNew
      blnNew = False
   Next x
or you could create an array of sheet names and then use that with the Sheets collection.

Thanks!
The code works well to select the sheets, but also need to move the selcted sheets to a new sheet.
How do I do that?
 
Upvote 0
Code:
Activewindow.selectedsheets.copy
would create a new workbook with the selected sheets. Or if you built an array of sheet names, you don't even need to select them:
Code:
Sheets(astrSheetNames).Copy
 
Upvote 0

Forum statistics

Threads
1,215,003
Messages
6,122,655
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top