title: End Loop in Excel VBA
body: <p>I have a excel VBA for a workbook.  How do I end a loop on the worksheets? I'm not sure on how to do that.  Here is the code.</p>
  
  <pre><code>Private Sub Workbook_SheetActivate(ByVal Sh As Object)
   Dim dtDate As Date
   Dim intHours As Long
   Dim ws As Worksheet
  
   intHours = 11
   dtDate = InputBox("Date", , Date)
  
   For Each ws In ThisWorkbook.Worksheets
   Set SelRange = Range("A6:A366")
   Next ws(**This where I need the loop to stop after the last worksheet**)
  
   For Each b In SelRange.Rows
   b.Value = dtDate + TimeSerial(intHours, 0, 0)
   b.Value = dtDate + TimeSerial(intHours, intMinutes, 0)
   intHours = intHours
   intMinutes = intMinutes + 1
   If intHours &gt; 24 Then
          intHours = intHours - 24
  
  End If
  Next
  End Sub
  </code></pre>
  
  <p>I need the loop to end after the last worksheet which is worksheet 6.</p>