Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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
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
Worksheets looping. Bob Phillips Excel Programming 0 December 6th 06 10:38 AM
Looping through Worksheets Steve Excel Programming 7 July 12th 05 07:56 PM
Looping through Worksheets Kirk P. Excel Programming 1 February 7th 05 05:14 PM
looping through worksheets Alex ekster Excel Programming 1 July 21st 03 03:16 AM
looping through worksheets alex Excel Programming 0 July 20th 03 06:43 PM


All times are GMT +1. The time now is 06:11 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"