title: Excel vba macro to insert rows only functioning properly on first worksheet
body: <p>I have a macro to insert row of data above a date if that date isn't today.  It then adds today's date in the date column.  This is done across 30 worksheets but only the first worksheet is properly adding a row in the correct place and adding a date in the right cell.  The row should be inserted above A3" on all of them but the rest insert a row above "A4".  Below is the current code i am using, i think it may be a range problem but had no luck when testing that.</p>
  
  <pre><code>    Sub UpdatePrices()
      Dim ws As Worksheet, Ldate As String, DateRng As Range
  Set DateRng = Sheets("AXP").Range("A3")    'date range is last date
  Ldate = DateRng.Value    'defines ldate as most recent date
  
  
  For Each ws In ThisWorkbook.Worksheets
      ws.Select
      'Inserts a new row with containing today's Date and exclude sheets
      If Ldate &lt;&gt; Date And UCase(ws.Name) &lt;&gt; "DATA" And UCase(ws.Name) &lt;&gt; "UPDATE" Then
          ws.Rows(DateRng.Row).EntireRow.Insert
          ws.Cells(DateRng.Row, DateRng.Column).Offset(-1, 0) = Date
      End If
  
  Next
  
  End Sub
  </code></pre>