title: Previous value in cell
body: <p>I have two columns, </p>
  
  <ol>
  <li>"<strong>Date</strong>" (Column <strong>H</strong>) </li>
  <li>"<strong>Previous Date in Cell</strong>" (Column <strong>I</strong>)</li>
  </ol>
  
  <p>I would like to use VBA to automatically keep the previous value of "Date" (Column H) and save the value before change in "Previous Date in Cell" (Column I). </p>
  
  <p>Ex. If <strong>H2</strong> = <strong>01-06-2018</strong> and the values is changed to <strong>02-06-2018</strong>, <strong>I2</strong> should than show <strong>01-06-2018</strong> as it is the previous value of the cell.</p>
  
  <p>I would like this code to work for a whole column of cells, not just a single cell. The values in columns <strong>H</strong> is not manually updated it comes from a formula that looks at a SQL pull out from a third party system. A lot of cells in columns <strong>H</strong> can therefore be changed simultaneously.</p>
  
  <p>Can you please help me? Thanks in advance. </p>
  
  <p>This is my code:</p>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
  Dim newVal As Variant
  If Target.Count &gt; 1 Then
      Exit Sub
  End If
  If Intersect(Range("H:H"), Target) Is Nothing Then
      Exit Sub
  End If
  Application.EnableEvents = False
  Application.ScreenUpdating = False
  newVal = Target.Value
  Application.Undo
  Target.Offset(0, 1).Value = Target.Value
  Target.Value = newVal
  Application.ScreenUpdating = True
  Application.EnableEvents = True
  </code></pre>
  
  <p>End Sub</p>