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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top