For example, you may want to track activities such as when was a particular expense incurred, what time did the sale invoice was created, when was the data entry done in a cell, when was the report last updated, etc. Let’s get started.
Keyboard Shortcut to Insert Date and Timestamp in Excel
If you have to insert the date and timestamp in a few cells in Excel, doing it manually could be faster and more efficient. Here is the keyboard shortcut to quickly enter the current Date in Excel: Here is how to use it:
Select the cell where you want to insert the timestamp. Use the keyboard shortcut Control + : This would instantly insert the current date in the cell.
A couple of important things to know:
This shortcut would only insert the current date and not the time. It comes in handy when you want to selectively enter the current date. It picks the current date from your system’s clock. Once you have the date in the cell, you can apply any date format to it. Simply go to the ‘Number Format’ drop-down in the ribbon and select the date format you want.
Note that this is not dynamic, which means that it will not refresh and change the next time you open the workbook. Once inserted, it remains as a static value in the cell. While this shortcut does not insert the timestamp, you can use the following shortcut to do this: This would instantly insert the current time in the cell.
So if you want to have both date and timestamp, you can use two different cells, one for date and one for the timestamp.
Using TODAY and NOW Functions to Insert Date and Timestamps in Excel
In the above method using shortcuts, the date and timestamp inserted are static values and don’t update with the change in date and time. If you want to update the current date and time every time a change is done in the workbook, you need to use Excel functions. This could be the case when you have a report and you want the printed copy to reflect the last update time.
Insert Current Date Using TODAY Function
To insert the current date, simply enter =TODAY() in the cell where you want it.
Since all the dates and times are stored as numbers in Excel, make sure that the cell is formatted to display the result of the TODAY function in the date format. To do this:
Right-click on the cell and select ‘Format cells’. In the Format Cells dialog box, select Date category in the Number tab. Select the required date format (or you can simply go with the default one). Click OK.
Note that this formula is volatile and would recalculate every time there is a change in the workbook.
Insert Date and Timestamp Using NOW Function
If you want the date and timestamp together in a cell, you can use the NOW function.
Again, since all the dates and times are stored as numbers in Excel, it is important to make sure that the cell is formatted to have the result of the NOW function displayed in the format that shows the date as well as time. To do this:
Right-click on the cell and select ‘Format cells’. In the Format Cells dialog box, select ‘Custom’ category in the Number tab. In the Type field, enter dd-mm-yyyy hh:mm:ss Click OK.
This would ensure that the result shows the date as well as the time. Note that this formula is volatile and would recalculate every time there is a change in the workbook.
Circular References Trick to Automatically Insert Date and Timestamp in Excel
One of my readers Jim Meyer reached out to me with the below query. This can be done using the keyboard shortcuts (as shown above in the tutorial). However, it is not automatic. With shortcuts, you’ll have to manually insert the date and timestamp in Excel. To automatically insert the timestamp, there is a smart technique using circular references (thanks to Chandoo for this wonderful technique). Let’s first understand what a circular reference means in Excel. Suppose you have a value 1 in cell A1 and 2 in cell A2. Now if you use the formula =A1+A2+A3 in cell A3, it will lead to a circular reference error. You may also see a prompt as shown below:
This happens as you are using the cell reference A3 in the calculation that is happening in A3. Now, when a circular reference error happens, there is a non-ending loop that starts and would have led to a stalled Excel program. But the smart folks in the Excel development team made sure that when a circular reference is found, it is not calculated and the non-ending loop disaster is averted. However, there is a mechanism where we can force Excel to at least try for a given number of times before giving up. Now let’s see how we can use this to automatically get a date and timestamp in Excel (as shown below).
Note that as soon as I enter something in cells in column A, a timestamp appears in the adjacent cell in column B. However, if I change a value anywhere else, nothing happens. Here are the steps to get this done:
Go to File –> Options. In the Excel Options dialog box, select Formulas. In the Calculated options, check the Enable iterative calculation option. Go to cell B2 and enter the following formula: =IF(A2<>"",IF(B2<>"",B2,NOW()),"")
That’s it! Now when you enter anything in column A, a timestamp would automatically appear in column B in the cell adjacent to it.
With the above formula, once the timestamp is inserted, it doesn’t update when you change the contents of the adjacent cell. If you want the timestamp to update every time the adjacent cell in Column A is updated, use the below formula (use Control + Shift + Enter instead of the Enter key):
This formula uses the CELL function to get the reference of the last edited cell, and if it’s the same as the one to the left of it, it updates the timestamp. Note: When you enable iterative calculations in the workbook once, it will be active until you turn it off. To turn it off, you need to go to Excel Options and uncheck the ‘Enable iterative calculation’ option.
Using VBA to Automatically Insert Timestamp in Excel
If VBA is your weapon of choice, you’ll find it to be a handy way to insert a timestamp in Excel. VBA gives you a lot of flexibility in assigning conditions in which you want the timestamp to appear. Below is a code that will insert a timestamp in column B whenever there is any entry/change in the cells in Column A. This code uses the IF Then construct to check whether the cell that is being edited is in column A. If this is the case, then it inserts the timestamp in the adjacent cell in column B. Note that this code would overwrite any existing contents of the cells in column B. If you want. You can modify the code to add a message box to show a prompt in case there is any existing content. Where to Put this Code? This code needs to be entered as the worksheet change event so that it gets triggered whenever there is a change. To do this:
Right-click on the worksheet tab and select View Code (or use the keyboard shortcut Alt + F11 and then double click on the sheet name in the project explorer). Copy-paste this code into the code window for the sheet. Close the VB Editor.
Make sure you save the file with .XLS or .XLSM extension as it contains a macro.
Creating a Custom Function to Insert Timestamp
Creating a custom function is a really smart way of inserting a timestamp in Excel. It combines the power of VBA with functions, and you can use it like any other worksheet function. Here is the code that will create a custom “Timestamp” function in Excel: Where to Put this Code? This code needs to be placed in a module in the VB Editor. Once you do that, the Timestamp function becomes available in the worksheet (just like any other regular function). Here are the steps to place this code in a module:
Press ALT + F11 from your keyboard. It will open the VB Editor. In the Project Explorer in VB Editor, right-click on any of the objects and go to Insert –> Module. This will insert a new module. Copy-paste the above code in the module code window. Close the VB Editor or press ALT + F11 again to go back to the worksheet.
Now you can use the function in the worksheet. It will evaluate the cell to its left and insert the timestamp accordingly.
It also updates the timestamp whenever the entry is updated. Make sure you save the file with .XLS or .XLSM extension as it contains VB code. Hope you’ve found this tutorial useful. Let me know your thoughts in the comments section.
How to Run a Macro in Excel. How to Create and Use an Excel Add-ins. Select Multiple Items from a Drop Down List in Excel. Inserting Date and Timestamp in Google Sheets. A Collection of FREE Excel Templates. Excel Timesheet Template. Excel Calendar Template. Convert Time to Decimal Number in Excel (Hours, Minutes, Seconds) How to Autofill Only Weekday Dates in Excel (Formula) Make VBA Code Pause or Delay (Using Sleep / Wait Commands)
=IF(A2″”,IF(AND(B2″”,CELL(“address”)=ADDRESS(ROW(A2),COLUMN(A2))),NOW(),IF(CELL(“address”)ADDRESS(ROW(A2),COLUMN(A2)),B2,NOW())),””) Works fine, but after keeping the sheet open for a few hours, while updating it, the timestamp gives an #N/A error and can’t get it back. I use the VBA timestamp function to get over this, seems to be working fine… Any ideas? Thank you =IF(B4″”,IF(AND(F4″”,CELL(“address”)=ADDRESS(ROW(B4),COLUMN(F4))),NOW(),IF(CELL(“address”)ADDRESS(ROW(B4),COLUMN(B4)),F4,NOW())),””) Works fine when it is on the same sheet, but its not working for different sheet even after changing the reference all B4 into Sheet1!B4 and looking output in the Sheet 2 in F4 Cell I need a timestamp on “C” that updates the time when either “A” or “B” is updated. I can’t use a macro as I need my file in Sharepoint and to be accessible by many people at the same time. How can I use the circular reference or the Custom Function for this purpose? Thanks! below sub : ——————————————————————– Sub Access_Filter() Dim WeekS As String Dim WeekE As String WeekS = “>=” & Application.InputBox(Prompt:=”Enter Start Date”, Default:=Format(Date, “dd mmm yyyy”), Type:=2) WeekE = “<=" & Application.InputBox(Prompt:=“Enter End Date”, Default:=Format(Date, “dd mmm yyyy”), Type:=2) ActiveSheet.ListObjects(“ACCESS”).Range.AutoFilter Field:=3, Criteria1:=WeekS, Operator:=xlAnd, Criteria2:=WeekE End Sub ———————————————————————————- Sub Access_Clear_All_Filters_Range() ‘To Clear All Fitlers use the ShowAllData method for ‘for the sheet. Add error handling to bypass error if ’no filters are applied. Does not work for Tables. On Error Resume Next ActiveSheet.ListObjects(“ACCESS”).Range.AutoFilter Field:=3 On Error GoTo 0 ActiveSheet.ListObjects(“ACCESS”).Range.End(xlDown).Select End Sub Function Timestamp(Reference As Range) If Reference.Value “” Then Timestamp = Format(Now, “dd-mm-yyy hh:mm:ss”) Else Timestamp = “” End If End Function is it possible to change “A2” to a range of cells? is it possible to change “A2” to a range of cells? I would like to use “A2:M2” as the affected cells, so the timestamp updates when any one of that range of cells is modified. I tried to change it but it would not work. I added another set of parentheses to each A2:M2 range, still no luck. In an example field C2 is also ‘monitored’ for change. It is a formula mess but it works. =IF(A2″”,IF(AND(B2″”,OR(CELL(“address”)=ADDRESS(ROW(A2),COLUMN(A2)),CELL(“address”)=ADDRESS(ROW(C2),COLUMN(C2)))),NOW(),IF(CELL(“address”)ADDRESS(ROW(A2),COLUMN(A2)),B2,NOW())),””) To solve this, I thought of getting : 1) Fixed, non-volatile timestamps as soon as ” found-clear” appears in column O for any PO entry. 2) To give Rank to these timestamps, using Rank Function. 3) Then use Index, Match, Rows to extract data in a sequential sorted manner. To get fixed( non-volatile) timestamps I applied two approaches as shown by you: 1) Circular reference with NOW() 2) UDF I’ve attached an excel file with two sheets: 1) Examples 2) Application Problem 1) with circular reference & NOW() 1A) Also if I change conditions so that “found-clear” is removed & then recreate the conditions to get “found-clear” back, timestamp disappears. Problem 2) with UDF; refer sheet” examples”, SAMPLE-3 2A) It is showing the year as 1989 in place of 2019. 2B) If I make any changes to the worksheet, like add or remove cells anywhere in the worksheet, all the timestamps change to current time & date. 2C) Rank function not working. I have a different requirement and this is for stock market. Let us say I have Columns A to G in the excel sheet and the columns heading reading as below for stock market : Symbol, Lot Size, Open, High, Low, LTP and the Signal Column (which gives Buy or Sell based on a strategy). The last column which is the Signal Column (and which happens to be Column G) contains the “Buy”or “Sell” or Ëmpty when there is no signal. This column is dynamic, in the sense, as and when the data across A-F changes, I get new signals like Buy or Sell or Empty, depending upon the strategy. My expectation is, as and when I get a Buy or a Sell or an empty in Column G (in the event of a Buy and Sell that has changed to an empty cell), I want to timestamp, let us say, Column H with the exact time the change happened (regardless of Buy or Sell or empty (post a buy or sell). And this timestamp should not change the time, unless any change happens in Column G. For e.g. a buy changing to a sell or a sell changing to a buy or a buy/sell changing to an empty cell. Let me know if the above explanation helps. Thanks Sumit, very nice contribution 🙂 To add to your article for those, who like to have a static value for Date or Time Stamp and need a specific date / time format but without going through VBA, you may consider this option:
- Choose one Reference Cell, e.g. [A1]. It can be on a separate worksheet. Put in the formula =today() or =now()
- Give that cell the name “Time” or “Date”
- Now, if you want to enter current Date or Time in any cell in your workbook, just type =Date or =Time The target cell can be formatted according to your preferences, e.g. “YYYY-MM-DD” or “hh:mm:ss”. The advantage is that you can also catch the seconds which is not possible with the keyboard shortcut [CTRL] + [SHIFT] + [:].
- You can also incorporate this in any formulas you are using in your worksheet. Example: Every time you enter the word “ok” in Row [C], Row [B] will automatically register the current time. To do this format Row [B] as “hh:mm:ss”. Now, in cell [B1] you enter the formula if(C1=”ok”,Time,””) Then you copy this formula to the range you will be using. Now, every time you enter “ok” in a cell on Row [C], you will get an automatic (and static) time stamp in the adjacent cell in Row [B]. is not worjking ??? Can you assist with one thing? I need to be able to create the timestamp, on a separate row, each time a (custom function) button is pressed? We will be using this to create a basic “footfall counter” to count the time/date and number of people passing into our IT support area. If you can assist, this would be amazing… using below code: Function Timestamp(Reference As Range) If Reference.Value <> “” Then Timestamp = Format(Now, “dd-mm-yyy hh:mm:ss”) Else Timestamp = “” End If End Function In cell C, should I use =timestamp(A1:B2) i CHECKED FOR ITERATION ALSO.. EVEN ITS NOT WORKING KINDLY HELP ON THIS THANK YOU SO MUCHHH!!!! Private Sub Workbook_Open() Application.Calculation = xlCalculationAutomatic Application.Iteration = True Application.MaxIterations = 1 End Sub That solves the problem and the formula works fine every time.