ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ITERATING THROUGH WORKSHEETS ! ! (https://www.excelbanter.com/excel-programming/427488-iterating-through-worksheets.html)

Jay Dean

ITERATING THROUGH WORKSHEETS ! !
 
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 ***

Gary Keramidas[_2_]

ITERATING THROUGH WORKSHEETS ! !
 
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

--


Gary

"jay dean" wrote in message
...
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 ***



Jay Dean

ITERATING THROUGH WORKSHEETS ! !
 
Thanks, Gary. This works fine !!

Jay

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

Don Guillett

ITERATING THROUGH WORKSHEETS ! !
 
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


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"jay dean" wrote in message
...
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 ***


Jay Dean

ITERATING THROUGH WORKSHEETS ! !
 
Thank you Don, and Gary !

Jay


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


All times are GMT +1. The time now is 11:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com