Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Loop through all sheets in workbook

No need to select objects.

If you use Worksheets.Count in the loop control statement, use the same
in the body of the loop.

Private Sub Workbook_Open()
Dim i As Long
For i = 1 To Worksheets.Count
Worksheets(i).Range("A1").Value = "Hello"
Next i
End Sub

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...

I think you want to do this

Private Sub Workbook_Open()

Dim i As Long

For i = 1 To Worksheets.Count

Sheets(i).select

Range("A1").Value = "Hello"

Next i

End Sub


--
Kaak
------------------------------------------------------------------------
Kaak's Profile:
http://www.excelforum.com/member.php...fo&userid=7513
View this thread: http://www.excelforum.com/showthread...hreadid=479367


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
Loop all Sheets not working. Pank New Users to Excel 12 February 27th 07 11:55 AM
Do..Loop in multi sheets norika Excel Programming 7 May 26th 05 07:44 AM
Loop through sheets michael Excel Programming 2 September 8th 04 02:52 PM
excel VBA - for loop for several sheets paku Excel Programming 2 April 11th 04 12:33 AM
Loop across Sheets and number of sheets Raj[_8_] Excel Programming 2 December 18th 03 09:18 AM


All times are GMT +1. The time now is 07:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"