A few years back when I was working for a tech company I was one of those people who were an Excel help point for all. And that’s the real reason I’m fascinated to learn more. One day the lady who was working as a reception coordinator came to me and asked:
Puneet, I’m managing a list of tasks and I want to add date and time in the corresponding cell on completion of each task. Which is the best way?
And quickly I realized that she was talking about a timestamp. I’m sure you also use it while working in Excel. In general, it contains the current date and time, and we use it to capture the completion time of a task. Now the thing is: Which is the best way to insert a timestamp in Excel?
In this post, you’ll learn how to create a timestamp in Excel using 5 different ways and we will try to figure out which is the best out of all. So let’s get started.
1. Using a Keyboard Shortcut to Insert a Timestamp
There are two different shortcuts to insert a date and a time. And, here we need to use both of them subsequently. Here are the steps:
- First of all, select the cell where you need to insert a timestamp.
- After that, use the shortcut key Control + : (Press and hold control and then press colon). Once you press this, it will insert the current date (according to your system) in the cell.
- At this time, your cell is in edit mode.
- Now, press Control + Shift + : (Press and hold the control and shift key and then press the colon).
- Your cell is still in edit mode, now press the enter key to complete the entry.
In short, you need to press two shortcuts in sequence to insert this. And, if you want to add only one thing of date and time, just skip the shortcut key.
If you want to save time and have fewer cells, this method is perfect.
This is not a dynamic method, you have a static timestamp. And if you want to update the time stamp you need to enter it again.
You need to press two different shortcut keys to enter it.
2. Insert a Timestamp with NOW Function
A simple dynamic method. If you want to use a formula to insert a timestamp, the perfect way is to use the NOW function. When you enter this function in a cell it returns the current date and time according to your system’s settings.
The default format of date and time return by NOW is mm/dd/yyyy hh:mm. But for some reason, if you want a custom format, you change its format using the custom format option. Select the cell ➜ Press shortcut key control + 1 ➜ Select “Custom” ➜ Enter “mm/dd/yyyy hh:mm” in the input box ➜ Click OK.
And if you want to enter the only date then you can use TODAY instead of NOW, it only returns the current date according to the system’s settings.
- It’s a dynamic method.
- You can use both of the functions with an IF function to create a condition to enter a timestamp if another cell has a value.
- Even though it’s a dynamic method but as both of the functions are volatile they will get updated whenever you make changes to your worksheet.
- And if you just want values instead of formulas you need to convert them into values manually.
3. Using Circular Reference for Creating a Timestamp
If you want to get into an advanced method and don’t want to use methods #1 and #2 then you can use a circular reference to insert a timestamp.
But before you learn this method let’s understand what circular reference is all about. Let’s say you have a value of 5 in cell A1 and a value of 10 in cell B1. Now if you enter a formula =A1+B1+C1 in cell C1, it will return a message circular reference error.
This is because you are using cell C1 as a reference in cell C1. When a circular reference error happens, there is a non-ending loop in the cell. Reference the cell A3 is dependent on the value of cell A3 and the value of A3 is dependent on reference to cell A3.
But when a circular reference is entered, Excel doesn’t calculate it and the non-ending loop never starts.
Here’s the deal:
You can enable the “iterative calculation option” to force Excel to perform the calculation at least one time and use the now function in the calculation. This way Excel will update the cell formula only one time instead of every time. Steps to enable iterative calculation option:
- Go to File ➜ Options.
- In the Excel options, select Formulas.
- In the Calculated options, check the Enable iterative calculation option.
- Click OK.
After that in cell B2, enter the below formula in the formula bar.
Now when you enter any value in cell A2 the formula in cell B2 will return a timestamp.
4. VBA to Add a Timestamp
If you are a VBA freak then I’m sure you’ll find this VBA code useful. With this, you don’t need to enter a formula or even not use any shortcut key. Just select the cell where you need to enter a timestamp and run the macro.
Sub timeStamp() Dim ts As Date With Selection .Value = Now .NumberFormat = "m/d/yyyy h:mm:ss AM/PM" End With End Sub
How to use this code
To use this code you can add it on QAT (quick access toolbar) and run it every time whenever you need to add a timestamp.
Here are the steps:
- Add this code in module by opening VBA editor.
- After that, go to File -> Options -> Quick Access Toolbar.
- Choose “Macros” from “Choose Command from” drop down.
- After that, add timeStamp macro to QAT.
- Now select that macro click modify button.
- Select an icon and click OK.
Now you have an icon on QAT and whenever you need a timestamp you can select the cell and click this button to insert it.
4.1 Using UDF for Timestamp
Yes, you can also create a custom Excel function for inserting a timestamp in Excel. Below is the code for this UDF.
Function Timestamp(Reference As Range) If Reference.Value <> "" Then Timestamp = Format(Now, "dd-mm-yyyy hh:mm:ss") Else Timestamp = "" End If End Function
By using this user-defined function you can get a timestamp in a cell if another has a value in it. Please follow the below steps:
- Go to Developer tab and open VBA editor.
- In VBA editor, insert a new module and paste this code into it.
- Now, close VBA editor and come back to your worksheet.
- In the cell B2, enter below formula.
- Now, when you enter any value in cell A1, cell B1 will get a timestamp.
Adding a timestamp is something we often do while working in Excel. And, you have 5 different methods to insert it. If you ask me I love to use the VBA button on QAT for this. The best way is to add this code in a personal.xlsb so that you can use it in all the workbooks. This is the whole story about timestamps and I’m sure you found it useful but now tell me one thing.
Do you know any other method for this?
Please share with me in the comment section, I’d love to hear from you, and please don’t forget to share this tip with your friends.
If you want to sharpen your existing Excel Skills, check out these Excel Tips and Tricks.