Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default selection of several worksheeets

Hi

I'd like to select several excel worksheets using a VBA macro.
I know: Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")).Select
But how can I do it without specifying each sheet name?
For example using something like ... from sheet 3 to sheet 8 ... .Select?

If possible, please help me.
Thank you.
Entaf

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default selection of several worksheeets

Sub AA()
Dim i as Long
for i = 3 to 8
worksheets(i).Select i = 3
Next
End sub

would be one way. Another is to build an array, then use that to select the
sheets

Sub AB()
Dim shlist()
Dim i As Long, k As Long
ReDim shlist(0 To 5)
i = 0
For k = 3 To 8
shlist(i) = Worksheets(k).Name
i = i + 1
Next
Worksheets(shlist).Select
End Sub

--
Regards,
Tom Ogilvy


"Enrico" wrote in message
...
Hi

I'd like to select several excel worksheets using a VBA macro.
I know: Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")).Select
But how can I do it without specifying each sheet name?
For example using something like ... from sheet 3 to sheet 8 ... .Select?

If possible, please help me.
Thank you.
Entaf



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default selection of several worksheeets

Thank you very much.
I got what I needed.

Entaf


Tom Ogilvy wrote:

Sub AA()
Dim i as Long
for i = 3 to 8
worksheets(i).Select i = 3
Next
End sub

would be one way. Another is to build an array, then use that to select the
sheets

Sub AB()
Dim shlist()
Dim i As Long, k As Long
ReDim shlist(0 To 5)
i = 0
For k = 3 To 8
shlist(i) = Worksheets(k).Name
i = i + 1
Next
Worksheets(shlist).Select
End Sub


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
Limiting selection in a cell AND linking that selection to a list Lisa Excel Discussion (Misc queries) 1 July 28th 09 05:00 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
Identifying a selection of a selection of a range swimfast Excel Worksheet Functions 1 March 1st 07 02:51 AM
Changing Selection for the "Center Across Selection" alignment johnandsuzie Excel Discussion (Misc queries) 1 January 18th 06 04:48 PM
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. jonH Excel Programming 3 June 7th 04 09:13 PM


All times are GMT +1. The time now is 02:09 PM.

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

About Us

"It's about Microsoft Excel"