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

I have a program in which I need to select multiple consecutive sheets and
perform a specific function. The sheets are sequential starting with Sheet4
all the way through Sheet23. I don't want to be concerned about the 'actual'
sheet names that the user may change periodically---therefore, I need to
reference the sheets based upon their underlying sheet reference as noted
above. Currently I am trying to use this code, but am getting a 'Type
Mismatch' error. Can someone tell me what I am doing wrong?

Sheets(Array(Sheet4, Sheet5, Sheet6, Sheet7, Sheet8, Sheet9, _
Sheet10, Sheet11, Sheet12, Sheet13, Sheet14, Sheet15, Sheet16, _
Sheet17, Sheet18, Sheet19, Sheet20, Sheet21, Sheet22, Sheet23)).Select

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

You could do a For Next statement something like this:

For i = 4 to 23

Sheets(i).select
'your code that does whatever goes here.
Next i
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"jday" wrote:

I have a program in which I need to select multiple consecutive sheets and
perform a specific function. The sheets are sequential starting with Sheet4
all the way through Sheet23. I don't want to be concerned about the 'actual'
sheet names that the user may change periodically---therefore, I need to
reference the sheets based upon their underlying sheet reference as noted
above. Currently I am trying to use this code, but am getting a 'Type
Mismatch' error. Can someone tell me what I am doing wrong?

Sheets(Array(Sheet4, Sheet5, Sheet6, Sheet7, Sheet8, Sheet9, _
Sheet10, Sheet11, Sheet12, Sheet13, Sheet14, Sheet15, Sheet16, _
Sheet17, Sheet18, Sheet19, Sheet20, Sheet21, Sheet22, Sheet23)).Select

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Selecting multiple sheets

In general macros do not operate on multiple sheets at once. So as a guess
what you are about to do will not work anyways. That being said Selecting a
sheet has an option argument to not deselect the previous sheet. So something
like this...

Sheet1.Select
Sheet2.Select Replace:=False
Sheet3.Select Replace:=False

--
HTH...

Jim Thomlinson


"jday" wrote:

I have a program in which I need to select multiple consecutive sheets and
perform a specific function. The sheets are sequential starting with Sheet4
all the way through Sheet23. I don't want to be concerned about the 'actual'
sheet names that the user may change periodically---therefore, I need to
reference the sheets based upon their underlying sheet reference as noted
above. Currently I am trying to use this code, but am getting a 'Type
Mismatch' error. Can someone tell me what I am doing wrong?

Sheets(Array(Sheet4, Sheet5, Sheet6, Sheet7, Sheet8, Sheet9, _
Sheet10, Sheet11, Sheet12, Sheet13, Sheet14, Sheet15, Sheet16, _
Sheet17, Sheet18, Sheet19, Sheet20, Sheet21, Sheet22, Sheet23)).Select

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Selecting multiple sheets

In general that code is a bad idea. It uses the index property of the sheet
to make the selection. When sheets are deleted or added the indexes get
changed and your code will now be operating on the wrong sheets...
--
HTH...

Jim Thomlinson


"Michael Arch" wrote:

You could do a For Next statement something like this:

For i = 4 to 23

Sheets(i).select
'your code that does whatever goes here.
Next i
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"jday" wrote:

I have a program in which I need to select multiple consecutive sheets and
perform a specific function. The sheets are sequential starting with Sheet4
all the way through Sheet23. I don't want to be concerned about the 'actual'
sheet names that the user may change periodically---therefore, I need to
reference the sheets based upon their underlying sheet reference as noted
above. Currently I am trying to use this code, but am getting a 'Type
Mismatch' error. Can someone tell me what I am doing wrong?

Sheets(Array(Sheet4, Sheet5, Sheet6, Sheet7, Sheet8, Sheet9, _
Sheet10, Sheet11, Sheet12, Sheet13, Sheet14, Sheet15, Sheet16, _
Sheet17, Sheet18, Sheet19, Sheet20, Sheet21, Sheet22, Sheet23)).Select

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
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 multiple sheets Dennis Excel Programming 2 January 1st 04 08:06 PM
selecting multiple sheets Young-Hwan Choi Excel Programming 2 November 24th 03 01:19 AM
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 05:40 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"