title: Format column with date to specific format - Excel VBA
body: <p>I am writing an excel vba macro.</p>
  
  <p>I have a large worksheet with over 10,000 rows.
  One of the columns has the date in this format: <code>10/28/13 06:57</code> with the Cells having a General Number for formatting.</p>
  
  <p>I would like to format it to have only four digits in this format: <code>mmdd</code> (1028 for the  example above)</p>
  
  <p>Here is what I have so far in the subroutine:</p>
  
  <pre><code>' This subroutine formats the columns to what is necessary for output
  Sub formatColumns()
      ' Set the LastRow variable to hold the last row number
      lastRow = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
  
      Dim cell As Range
  
      For Each cell In Range("B3:B" &amp; lastRow)
          cell.NumberFormat = "mmdd;@"
      Next
  End Sub
  </code></pre>