Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Worksheet arrays VBA

I'm trying to progamitically select a group of sheets with "CC" as part of
the name, they are always in one block but may vary in the collection of
sheets. I can find their start and finish index no's but how do I use this
in the "Sheets.Array" command - see code below.

Sub Test()
Dim WKS
Dim intStart As Byte
Dim intEnd As Byte
Dim intcnt As Byte

intStart = 0
intEnd = 0

For Each WKS In Worksheets
If InStr(UCase(WKS.Name), "CC") 0 Then
If intStart = intEnd Then
intStart = WKS.Index
Else
intEnd = WKS.Index
End If
End If
Next

MsgBox "Start = " & intStart & " End = " & intEnd

For intcnt = intStart To intEnd

'now how to I program this with the above info?????
Sheets(Array("cc-1", "cc-2", "cc-3", "cc-4")).Select

Next

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Worksheet arrays VBA

Sub Test()
Dim WKS
Dim SheetNames As String
Const SHEET_ID As String = "SHEET"


intStart = 0
intEnd = 0

For Each WKS In Worksheets
If InStr(UCase(WKS.Name), SHEET_ID) 0 Then
SheetNames = SheetNames & WKS.Name & ","
End If
Next
If SheetNames < "" Then SheetNames = Left$(SheetNames,
Len(SheetNames) - 1)

MsgBox SheetNames

Sheets(Split(SheetNames, ",")).Select

End Sub


--
__________________________________
HTH

Bob

"Phil G" wrote in message
...
I'm trying to progamitically select a group of sheets with "CC" as part of
the name, they are always in one block but may vary in the collection of
sheets. I can find their start and finish index no's but how do I use this
in the "Sheets.Array" command - see code below.

Sub Test()
Dim WKS
Dim intStart As Byte
Dim intEnd As Byte
Dim intcnt As Byte

intStart = 0
intEnd = 0

For Each WKS In Worksheets
If InStr(UCase(WKS.Name), "CC") 0 Then
If intStart = intEnd Then
intStart = WKS.Index
Else
intEnd = WKS.Index
End If
End If
Next

MsgBox "Start = " & intStart & " End = " & intEnd

For intcnt = intStart To intEnd

'now how to I program this with the above info?????
Sheets(Array("cc-1", "cc-2", "cc-3", "cc-4")).Select

Next

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Worksheet arrays VBA

Bob - thanks for that - code is exactly what I was looking for - "Split" -
I'll remember that.

Ta - Phil

"Bob Phillips" wrote:

Sub Test()
Dim WKS
Dim SheetNames As String
Const SHEET_ID As String = "SHEET"


intStart = 0
intEnd = 0

For Each WKS In Worksheets
If InStr(UCase(WKS.Name), SHEET_ID) 0 Then
SheetNames = SheetNames & WKS.Name & ","
End If
Next
If SheetNames < "" Then SheetNames = Left$(SheetNames,
Len(SheetNames) - 1)

MsgBox SheetNames

Sheets(Split(SheetNames, ",")).Select

End Sub


--
__________________________________
HTH

Bob

"Phil G" wrote in message
...
I'm trying to progamitically select a group of sheets with "CC" as part of
the name, they are always in one block but may vary in the collection of
sheets. I can find their start and finish index no's but how do I use this
in the "Sheets.Array" command - see code below.

Sub Test()
Dim WKS
Dim intStart As Byte
Dim intEnd As Byte
Dim intcnt As Byte

intStart = 0
intEnd = 0

For Each WKS In Worksheets
If InStr(UCase(WKS.Name), "CC") 0 Then
If intStart = intEnd Then
intStart = WKS.Index
Else
intEnd = WKS.Index
End If
End If
Next

MsgBox "Start = " & intStart & " End = " & intEnd

For intcnt = intStart To intEnd

'now how to I program this with the above info?????
Sheets(Array("cc-1", "cc-2", "cc-3", "cc-4")).Select

Next

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
Array function, two dimensions?? and worksheet arrays Neal Zimm Excel Programming 7 October 3rd 05 09:16 PM
Linking arrays and Worksheet names gsimmons2005 Excel Worksheet Functions 2 August 18th 05 04:54 PM
Worksheet names to variant arrays Alasdair Stirling[_3_] Excel Programming 3 August 3rd 05 01:48 PM
Using Excel Worksheet functions in Arrays The Roon Excel Programming 1 January 13th 05 05:05 AM


All times are GMT +1. The time now is 08:35 AM.

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"