Forum Discussion

AHKOVC's avatar
AHKOVC
Copper Contributor
Dec 30, 2020

Time stamp Data entry in Excel

I am trying to record date and time in a cell whenever data is entered into a worksheet. I hav tried "+@LastModified()" but it is not doing what I want. Any suggestions ?

 

1 Reply

  • AHKOVC 

    You need VBA for this. A formula cannot do what you want.

    Right-click the sheet tab.

    Select 'View Code' from the context menu.

    Copy the following code into the worksheet module:

     

    Private Sub Worksheet_Change(ByVal Target As Range)
        Application.EnableEvents = False
        ' Change C1 to the cell in which you want the time stamp
        Range("C1").Value = Now
        Application.EnableEvents = True
    End Sub

     

    Switch back to Excel.

    Save the workbook as a macro-enabled workbook (.xlsm).

    Make sure that you allow macros when you open the workbook.

Resources