LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 989
Default sheets(array).select problem

I've tried various formats of array contents in sheets(array).select, and
always get a subscript out of range error. I've used (1, 2, 3), ("sheet1",
"sheet2", "sheet3"), and others. I DO have multiple sheets, and have
verified that the ones in the array actually exist.

My current code:

Dim mySheet As Worksheet

For Each mySheet In ActiveWorkbook.Sheets

Worksheets(mySheet.Name).Activate

If ActiveSheet.Tab.ColorIndex = 3 Then 'this is a red tab worksheet

If sheetlist = "" Then
sheetlist = mySheet.Index
Else
sheetlist = sheetlist & ", " & mySheet.Index
End If

End If

Next

Sheets(sheetlist).Select

End Sub

Sheetlist contents when it crashes on select statement:

31, 32, 33, 36

But it crashes if I change the code so that sheetlist contents a

"sheet31, "sheet32", "sheet33", "sheet36"

 
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
Problem using newly created user function in Excel 2003 Richard Excel Discussion (Misc queries) 10 January 22nd 07 12:44 AM
have some problem with database baldamenti Excel Discussion (Misc queries) 1 October 13th 05 05:38 PM
Urgent Help Required on Excel Macro Problem Sachin Shah Excel Discussion (Misc queries) 1 August 17th 05 06:26 AM
Problem With Reference Update Egon Excel Worksheet Functions 17 July 16th 05 05:45 AM
Freeze Pane problem in shared workbooks JM Excel Discussion (Misc queries) 1 February 1st 05 12:04 AM


All times are GMT +1. The time now is 06:23 AM.

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"