Loop through all Worksheets

March 15th, 2007

Here's a simple procedure that demonstrates how to loop through the worksheet objects in a workbook. The procedure loops through all worksheets in the active workbook and puts the names of each worksheet in Column A of the active sheet.

Sub LoopThroughSheets()
    Dim ws As Worksheet
   
    For Each ws In ActiveWorkbook.Worksheets
        ActiveSheet.Range("A" & ws.Index) = ws.Name
    Next ws
   
End Sub

Posted in Excel, VBA | No Comments




No Comments yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment



(C) by Virgilio Adriano. All rights reserved. Powered by WordPress.
Entries and comments feeds.
It took 0.336 seconds to load this page.