title: Loop until last worksheet
body: <p>I am trying to apply a format to every worksheet in my current workbook.  I have tried "For Each" and I have tried to Loop through until I reach last worksheet but both error due to different reasons.  Can someone please tell me what I'm doing wrong?</p>
  
  <p>Method 1: It works on the 1st worksheet but not on the remaining worksheets.</p>
  
  <pre><code>Sub format_worksheets()
  
      Dim ws As Worksheet
      For Each ws In Worksheets
  
          Columns("A:A").Select
  
             Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
                  TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
                  Semicolon:=False, Comma:=True, Space:=False,     
                  Other:=True,TrailingMinusNumbers:=True
  
          Range("A1").Select
  
      Next ws
  
  
  End Sub
  </code></pre>
  
  <p>Method 2:  It doesn't recognise the last worksheet.</p>
  
  <pre><code>Sub format_worksheets()
  
      Dim ws As Worksheet
  
      ws = Worksheet.Active
  
      Do
  
          code
  
      Loop Until ws = Sheets(Sheets.Count).Active
  
  End Sub
  </code></pre>