Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Aug 2001
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Traversing Sheets in a Book (2000)

    Thanks to this board, I am familiar with looping to traverse through cells using Offset. I need to traverse through all sheets in a book. Is this possible?

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Traversing Sheets in a Book (2000)

    You can use the following code to loop through all sheets in the active workbook.<pre>Sub TraverseSheets()
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.WorkSheets
    MsgBox ws.Name
    Next
    End Sub</pre>


    Andrew C

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Traversing Sheets in a Book (2000)

    If you have chart sheet s you could use the following <pre>Sub TraverseCharts()
    Dim cht As Chart
    For Each cht In ActiveWorkbook.Charts
    MsgBox cht.Name
    Next
    End Sub</pre>


    If you want to traverss all sheets, i.e. Worksheets and Chartsheets then use <pre>Sub TraverseSheets()
    Dim sh As Object
    For Each sh In ActiveWorkbook.Sheets
    MsgBox sh.Name
    Next
    End Sub</pre>


    Andrew

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •