title: How can I loop through a subset of worksheets?
body: <p>I know how to loop through all the worksheets in a workbook, and how to exit once I reach an 'end-flag' worksheet:</p>
  
  <pre><code>For Each ThisWorkSheet In Worksheets
     If ThisWorkSheet.Name = "FlagEnd" Then Exit For
     MsgBox "This worksheet name is: " &amp; ThisWorkSheet.Name
  Next
  </code></pre>
  
  <p>However I cannot get the loop to begin on a 'start-flag' worksheet (or even better on the worksheet right after the start-flag worksheet. For example the flagged start/end worksheets are in the middle of a bunch of other worksheets, so beginning or end traversing is not workable. </p>
  
  <p>There could be hundreds of worksheets before that 'FlagStart' sheet, so I really need to start on the right sheet.</p>
  
  <p>Tried:</p>
  
  <pre><code>Set ThisWorkSheet = Sheets("FlagNew")
  </code></pre>
  
  <p>and </p>
  
  <pre><code>For Each Sheets("FlagNew") In Worksheets
  </code></pre>
  
  <p>Ideas?</p>
  
  <p>Solution:
  Mathias was very close, but dendarii was that tiny step closer with the custom ending index. I actually figured out my final solution on my own, but wanted to give credit. Here was my final solution:</p>
  
  <pre><code>Private Sub CommandButtonLoopThruFlaggedSheets_Click()
      ' determine current bounds
      Dim StartIndex, EndIndex, LoopIndex As Integer
      StartIndex = Sheets("FlagNew").Index + 1
      EndIndex = Sheets("FlagEnd").Index - 1
  
      For LoopIndex = StartIndex To EndIndex
          MsgBox "this worksheet is: " &amp; Sheets(LoopIndex).Name
          ' code here
      Next LoopIndex
  End Sub
  </code></pre>