title: VBA code to autoupdate cell with current date, when cell changed, not working
body: <p>I have a sheet where I daily change the stats of some rows and I have to know when the stats changed. To make my life easier, I found on the internet this VBA code:</p>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
  
      If Intersect(Target, Range("R1:R2000")) Is Nothing Then Exit Sub
      Target.Offset(0, 1) = Date
  
  End Sub
  </code></pre>
  
  <p>The code works wonderfully. Everytime I change de stats on column R, it update the date on column S. </p>
  
  <p>The problem is that I change this stat in a table linked to an outside source (Oracle Database) and if I try to refresh the table, it change the entire content of the table to different dates. What I have to do now is, everytime I have to refresh the table, I just comment the entire VBA Code.</p>
  
  <p>Is there anything I can change on the code so it doesn't update when I refresh the table?</p>
  
  <p>Edit 1:</p>
  
  <pre><code>Sub RefreshOracleTable()
      Application.EnableEvents = False
  
  
      If Intersect(Target, Range("R1:R200000")) Is Nothing Then Exit Sub
      Target.Offset(0, 1) = Date
  
      ThisWorkbook.Sheets("wsTables").ListObjects("OracleTable").QueryTable.Refresh BackgroundQuery:=Application.EnableEvents = True
  
  End Sub
  </code></pre>