Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looping through worksheets
What's the easiest way to loop through worksheets?
I can't use Sheet(1) reference because the sheet numbers will change, I'll have to use the actual name. I'll need to do some formatting on each sheet. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looping through worksheets
Hi RominallL
Try this Dim sh As Worksheet For Each sh In ThisWorkbook.Worksheets sh.Range("A1").Interior.ColorIndex = 3 Next sh -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "RominallL" wrote in message ... What's the easiest way to loop through worksheets? I can't use Sheet(1) reference because the sheet numbers will change, I'll have to use the actual name. I'll need to do some formatting on each sheet. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looping through worksheets
Sub marine()
For Each w In Worksheets w.Activate Range("A1").Interior.ColorIndex = 6 Next End Sub -- Gary's Student gsnu200703 "RominallL" wrote: What's the easiest way to loop through worksheets? I can't use Sheet(1) reference because the sheet numbers will change, I'll have to use the actual name. I'll need to do some formatting on each sheet. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looping through worksheets
Ooops, forgot to mention that there are 3 sheets that won't get the
formatting. And those names will not change. "Ron de Bruin" wrote: Hi RominallL Try this Dim sh As Worksheet For Each sh In ThisWorkbook.Worksheets sh.Range("A1").Interior.ColorIndex = 3 Next sh -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "RominallL" wrote in message ... What's the easiest way to loop through worksheets? I can't use Sheet(1) reference because the sheet numbers will change, I'll have to use the actual name. I'll need to do some formatting on each sheet. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looping through worksheets
Try this
Change a, b, c to your sheet names Dim sh As Worksheet For Each sh In ThisWorkbook.Worksheets If sh.Name < "a" And sh.Name < "b" And sh.Name < "c" Then sh.Range("A1").Interior.ColorIndex = 3 End If Next sh -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "RominallL" wrote in message ... Ooops, forgot to mention that there are 3 sheets that won't get the formatting. And those names will not change. "Ron de Bruin" wrote: Hi RominallL Try this Dim sh As Worksheet For Each sh In ThisWorkbook.Worksheets sh.Range("A1").Interior.ColorIndex = 3 Next sh -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "RominallL" wrote in message ... What's the easiest way to loop through worksheets? I can't use Sheet(1) reference because the sheet numbers will change, I'll have to use the actual name. I'll need to do some formatting on each sheet. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Worksheets looping. | Excel Programming | |||
Looping through Worksheets | Excel Programming | |||
Looping through Worksheets | Excel Programming | |||
looping through worksheets | Excel Programming | |||
looping through worksheets | Excel Programming |