Static timestamp in excel
I'd like to be able to add a timestamp at the click of a button to an excel cell. Unfortunately doing =Now() will always update to the current time, and thus is not static.
I could do F5 in notepad, and then transfer it to excel, but i'd rather cut out the middle man.
Create a button next to a cell.
Then for the VBA code inside of that button's "onclick" event do something like this:
Sheets("Sheetname").Range("C1").value = time()
Or for date & time
Sheets("Sheetname").Range("C1").value = Now()
Either way only when the button is clicked will the value of that cell be set to the current time.
If you've never inserted a button object into excel here is a step-by-step guide for Excel 2003,2007, and 2010
If you only want to add the timestamp to the currently selected cell then use the following line of code:
ActiveCell.value = Now()
You might not really need a button if you just use Ctrl+Shift+: help says Ctrl+: but don't forget to use Shift to get that.
None of the examples I have seen really simply do what is asked. (Note Using Excel 2010)
Here is a simple macro. I saved the worksheet macro enabled and I added a QuickAccess Toolbar button to run it.
Sub MyTimeStamp() Dim DT ' ' MyTimeStamp Macro ' ' Keyboard Shortcut: Ctrl+t ' DT = Format(Now, "mm/dd/yyyy hh:mm:ss AM/PM") ActiveCell.Select Selection.NumberFormat = "mm/dd/yyyy hh:mm AM/PM" ActiveCell.Value = DT End Sub