title: Display old and new values for a cell
body: <p>I have a worksheet that logs changes that uses have made to cells. It goes as follows </p>
  
  <pre><code>Public OldVal As String
  Public NewVal As String
  
  
  Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  
  If Target.Cells.Count &gt; 1 Or IsEmpty(Target) Then Exit Sub
  OldVal = Target.Value
  End Sub
  
  
  Private Sub Worksheet_Change(ByVal Target As Range)
  Dim LDate As String
  
  If Target.Cells.Count &gt; 1 Then Exit Sub
  NewVal = Target.Value
  Sheets("corrections").Cells(Rows.Count, "A").End(xlUp)(2).Value = Now &amp; "_Sheet " &amp; ActiveSheet.Name &amp; " Cell " &amp; Target.Address(0, 0) &amp; " was changed from '" &amp; OldVal &amp; "' to '" &amp; NewVal &amp; "'"
  OldVal = ""
  NewVal = ""
  End Sub
  </code></pre>
  
  <p>The problem im having is that for some reason it will never display the previous value. it will output it only as Sheet FA Cell B5 was changed from '' to '12' even if say for example 10 was in the cell prviously.</p>
  
  <p>I also was curious to know is there a way that you can have it so that this code is not running at all times. Id prefer to have a button you click and at that point it will initiate and start logging changes.</p>
  
  <p>Thanks</p>