Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default select/group sheets dependent on criteria

Hi all, I wonder if you could offer some advice, please.

I am generating a number of worksheets within a workbook. I then want to
group some of them and copy them to another workbook. The names of the
worksheets I am interested in all end in "DWM".

If I manually select the sheets and record the actions, I get:

Sheets(Array("Sunderland DWM", "Manchester DWM", "Coventry DWM")).Select


So, I thought, I just need to loop through the sheets and build the string
....

Dim ArrayList as String
For Each Sheet In Sheets
If Right(Sheet.Name, 3) = "DWM" And Sheet.Name < "Blank DWM" Then
If ArrayList = "" Then
ArrayList = """" & Sheet.Name & """"
Else
ArrayList = ArrayList & ", " & """" & Sheet.Name & """"
End If
End If
Next

But, when I try to select the sheets based on the string I have built up ...

Sheets(Array(ArrayList)).Select

.... I get Run-time error '9': Subscript out of range

ArrayList contains: "Sunderland DWM", "Manchester DWM", "Coventry DWM"

Any suggestions as to how to get this to work ... or offer a better way ?

Thanks and Regards

Trevor



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
Copying data from one workbook to another dependent on user select sarahphonics Excel Discussion (Misc queries) 1 April 19th 10 04:37 PM
select dependent cells in the result cell GireeshaJ Excel Discussion (Misc queries) 0 February 11th 09 12:34 PM
Using VBA select sll sheets based on Criteria on each sheet. AirgasRob Excel Discussion (Misc queries) 4 September 3rd 08 03:11 PM
Multi select dependent on cell in range John Excel Programming 0 August 30th 06 04:46 PM


All times are GMT +1. The time now is 08:02 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"