Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default selecting multiple sheets

How do I select multiple sheets?
What I want to do is to move some sheets to a new workbook.

Moving the sheets is inside For ~ next. Generating several sheets is also in
the For ~ Next. The number of sheets changes. When I record a macro for this
job, the code looks like Sheets(Array(sheet1, sheet2,.....)) According to
the recording, I have to type all the sheets I want to move.

Is there any better method for selecting multiple sheets, let's say from
sheets1 to sheets 50, like Range("A1:A30")?

thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default selecting multiple sheets

You could use something like the following to move the first 50 sheets from the active workbook to a new workbook:

Sub MoveSheets()
Dim shtArray() As Integer
Dim i As Integer

For i = 1 To 50
ReDim Preserve shtArray(1 To i)
shtArray(i) = i
Next i

Sheets(shtArray).Move
End Sub


--

John Green - Excel MVP
Sydney
Australia


"Young-Hwan Choi" wrote in message ...
How do I select multiple sheets?
What I want to do is to move some sheets to a new workbook.

Moving the sheets is inside For ~ next. Generating several sheets is also in
the For ~ Next. The number of sheets changes. When I record a macro for this
job, the code looks like Sheets(Array(sheet1, sheet2,.....)) According to
the recording, I have to type all the sheets I want to move.

Is there any better method for selecting multiple sheets, let's say from
sheets1 to sheets 50, like Range("A1:A30")?

thanks.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default selecting multiple sheets

John,

I've just changed "i=1 to 50" to "i = 8 to sheets.count" and "shtArrary(1 To
i)" to "shtArray(8 to i)" in your coding, as I want to move 8th ~ the last
sheet to the new book.
Although I'm not sure whether what I've done is right or not, it does what I
want beautifully.

I appreciate your help.

regards,
choi.

"John Green" wrote in message
...
You could use something like the following to move the first 50 sheets

from the active workbook to a new workbook:

Sub MoveSheets()
Dim shtArray() As Integer
Dim i As Integer

For i = 1 To 50
ReDim Preserve shtArray(1 To i)
shtArray(i) = i
Next i

Sheets(shtArray).Move
End Sub


--

John Green - Excel MVP
Sydney
Australia


"Young-Hwan Choi" wrote in message

...
How do I select multiple sheets?
What I want to do is to move some sheets to a new workbook.

Moving the sheets is inside For ~ next. Generating several sheets is

also in
the For ~ Next. The number of sheets changes. When I record a macro for

this
job, the code looks like Sheets(Array(sheet1, sheet2,.....)) According

to
the recording, I have to type all the sheets I want to move.

Is there any better method for selecting multiple sheets, let's say from
sheets1 to sheets 50, like Range("A1:A30")?

thanks.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vba for selecting multiple sheets to save as a new book Sharon Excel Worksheet Functions 5 March 16th 07 12:53 AM
Selecting Multiple Sheets in VBA Gizmo63 Excel Worksheet Functions 4 May 8th 06 01:50 PM
selecting multiple sheets Shaun Excel Worksheet Functions 1 August 31st 05 04:09 PM
Selecting sheets - II Dr.Schwartz Excel Discussion (Misc queries) 4 July 25th 05 02:31 PM
Changing the value in multiple sheets without selecting those sheets herm Excel Programming 3 October 14th 03 03:50 PM


All times are GMT +1. The time now is 11:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"