title: How do I set an Excel cell to the current date using VBA?
body: <p>I am running into an error when trying to set an excel cell to the current date whenever somebody makes a change in other cells in the worksheet.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>Dim EditDate As Date
  
  RowNum = ActiveCell.Row
  ColNum = ActiveCell.Column
  
  If ColNum = 11 Or ColNum = 13 Or ColNum = 19 Or ColNum = 20 Or ColNum = 21 Or ColNum = 22 _
  Or ColNum = 23 Or ColNum = 24 Then
  
      Application.EnableEvents = False
  
      EditDate = Date()
      ActiveWorksheet.Range("Y," &amp; RowNum).Value = EditDate
  
      Application.EnableEvents = True
  
  End If
  </code></pre>
  
  <p>I am getting an object required error every time I try to make a change in one of these cells. How can I make this work??</p>