Insert a Permanent Timestamp When an Excel Cell Changes
Question details
Record a fixed date and time in one cell when a neighboring Excel cell is entered or updated.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet tracks unit sign-in and sign-out times alongside entered data.
- Observed behavior
- The user wants a timestamp in C6 when B6 is entered or updated, without the timestamp changing during later recalculations.
Open the workbook in desktop Excel and identify the worksheet containing B6 and C6. Confirm that C6 is available for the timestamp and that you can enable macros from a trusted source.
Use a Worksheet Change Event to Timestamp B6
Use VBA to write a fixed timestamp to C6 whenever B6 is entered or updated.
The timestamp updates each time B6 is edited and is cleared if B6 is cleared. Unlike a NOW() formula, the stored value does not change when the workbook recalculates.
In desktop Excel, right-click the relevant worksheet tab and select View Code.
Paste this code into the worksheet's code window: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Me.Range("B6")) Is Nothing Then Exit Sub On Error GoTo CleanUp Application.EnableEvents = False If Len(Me.Range("B6").Value2) > 0 Then Me.Range("C6").Value = Now Me.Range("C6").NumberFormat = "yyyy-mm-dd hh:mm:ss" Else Me.Range("C6").ClearContents End If CleanUp: Application.EnableEvents = True End Sub
Return to Excel, select File > Save As, and choose Excel Macro-Enabled Workbook (*.xlsm).
If prompted when opening the trusted workbook, select Enable Content. Enter or edit a value in B6 and check that C6 shows the current date and time.

Manage Time-Tracking Workbooks in WPS Spreadsheet
WPS Office is a free, lightweight Office alternative with a familiar spreadsheet interface. Open compatible Excel workbooks and move everyday time-tracking tasks to WPS easily; check macro compatibility before relying on an Excel VBA event.

Frequently Asked Questions
Why doesn't =IF(B6<>"",NOW(),"") preserve the entry time?
NOW() is volatile, so its result can update when Excel recalculates. A worksheet change macro writes the current time as a fixed value instead.
Will the timestamp change if I edit B6 again?
Yes. The provided macro writes a new timestamp to C6 each time B6 is edited. Clearing B6 also clears C6.
Why isn't the timestamp appearing?
Make sure the code is in the correct worksheet's code window, the workbook is saved as an XLSM file, and macros are enabled for the trusted workbook. Also check that B6 was edited directly rather than changed only by a formula recalculation.
Can I record sign-in and sign-out in separate cells?
Yes. Use separate input and timestamp cells for each event, and adapt the worksheet change code to check each input cell and write to its corresponding timestamp cell.




