Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping Code through a WorkBook

Status
Not open for further replies.

pcdaveh

Technical User
Sep 26, 2000
213
US
Does anyone have some code that will allow me to perform the same procedure on every Worksheet in a Workbook?

How do you Set up a for next loop that will iterate through each worksheet?

 
Hello, pcdaveh.

Worksheets as a collection
Dim ws As Worksheet
For Each ws in Worksheets
MsgBox (ws.Name)
Next
Or
Worksheets as an array
Dim i As Integer
For i = 1 To Worksheets.Count
MsgBox (Worksheet(i).Name)
Next

regards - tsuji
 
A shorty

Dim i as Integer
For i = 1 To Sheets.Count
'your code
Next


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top