ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Need help building a macro that displays date/time in active cell (https://www.excelbanter.com/excel-discussion-misc-queries/239379-need-help-building-macro-displays-date-time-active-cell.html)

MSUser

Need help building a macro that displays date/time in active cell
 


Rick Rothstein

Need help building a macro that displays date/time in active cell
 
Here is a macro to do what you asked for...

Sub InsertDateTime()
ActiveCell.Value = Now
ActiveCell.NumberFormat = "mmm d, yyyy - h:mm:ss AM/PM"
End Sub

Note that unlike the worksheet function NOW(), the date/time entered into
the active cell by this code will be fixed at the date and time the code was
executed.

--
Rick (MVP - Excel)


"MSUser" wrote in message
...




All times are GMT +1. The time now is 11:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com