ITERATING THROUGH WORKSHEETS ! !

J

jay dean

Hi - Two questions:

1. I am looping through worksheets in a workbook. However, I do not want
to loop through any sheets that contain the color yellow (i.e,
colorindex 6)in any cell. The sheets many and any help would be
appreciated.

2. Also, if there are say about 25 sheets in a workbook labeled in order
from "SheetA", "SheetB", "SheetC".....though "SheetY", how do I loop
through ONLY from say "SheetN" through "SheetY" without using "if
sht.name<>"..." OR "if sht.name="..." so many times?

Thanks
Jay


*** Sent via Developersdex http://www.developersdex.com ***
 
G

Gary Keramidas

here's one way if they're in order

Sub test()
Dim i As Long
For i = 13 To 25
Worksheets(i).Activate
Next
End Sub
 
D

Don Guillett

question 1

Sub countcolorinsheet()
For Each ws In Worksheets
counter = 0
For Each c In ws.UsedRange
If c.Interior.ColorIndex = 6 Then
counter = counter + 1
Exit For
Else
End If
Next c
If counter < 1 Then
MsgBox ws.Name
End If
Next ws
End Sub
 
Top