February 03, 2009
Excel VBA - Iterate Application.Sheets

I was writing a macro to create an Index tab and couldn't find anything directly related to iterating through the Sheets collection. You can't hyperlink to a Chart tab nor does it have a Cells() method so the index entry processing needs to be different. Anyway, this code extract works for me. YKMV

  Dim mySht as Object

  For Each mySht In Application.Sheets
    If mySht.Type = xlWorksheet Then
      ' Process a Worksheet tab
    Else
      ' Process a Chart tab
    End If
  Next mySht
 
Posted by jservice at February 03, 2009 12:16 PM
Comments