-1

I am using Excel 2013 on a PC running Windows 7. In Excel, if cell A1 changes from one value to another, I would like a date time stamp to appear in cell B1. Assume cell A1 could be blank or filled at the time of the change. Also, assume I want the date time stamp to occur automatically at the moment A1 is changed. Can you please help? Thank you. VBA or formula is fine. Thanks.

  • Welcome to Super User. New members commonly mistake this for a service site where we will do the work. It is a Q&A community where specific questions are asked after you have attempted something and get stuck. Please add details of what you have tried so far, including scripts, code or formulas, and we will try to help. If you need more info about asking questions, check out *[ask]* in the *[help]*. – CharlieRB Mar 16 '16 at 18:46

1 Answers1

1

Add the following event sub to the sheet you wish to update:

Private Sub Worksheet_Change(ByVal Target As Range)
    If (Target = Range("A1")) Then
        Range("B1").Value = Format(Now(), "yyyy-MM-dd hh:mm:ss")
    End If
End Sub

Of course, this only affects cell A1. If you want all cells in A to update it's relevant column B, use the following:

Private Sub Worksheet_Change(ByVal Target As Range)
    If (Target.Column = 1) Then
        Cells(Target.Row, 2).Value = Format(Now(), "yyyy-MM-dd hh:mm:ss")
    End If
End Sub

Naturally you can change the cell output as you require.

Jonno
  • 21,217
  • 4
  • 64
  • 71