ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Insert Time Stamp when macro is run (https://www.excelbanter.com/excel-discussion-misc-queries/134562-insert-time-stamp-when-macro-run.html)

Nagesh

Insert Time Stamp when macro is run
 
Hi All,

I'm generating reports using macros. I would like to Insert a time stamp
when the macro is run. Can you please let me know how?

I'm aware of =Now() to insert time stamp. But like to insert actual time
when the user runs the macro.

Thanks,
Nagesh

JE McGimpsey

Insert Time Stamp when macro is run
 
One way:

Public Sub try()
Range("A1").Value = Time
'rest of the macro
End Sub

In article ,
Nagesh wrote:

Hi All,

I'm generating reports using macros. I would like to Insert a time stamp
when the macro is run. Can you please let me know how?

I'm aware of =Now() to insert time stamp. But like to insert actual time
when the user runs the macro.

Thanks,
Nagesh


Nagesh

Insert Time Stamp when macro is run
 
Hi JE McGimpsey,

Your solution works, but the date is inserted as 1/1/1900..I have instead
used =now() instead of Time

Thanks for getting me going


"JE McGimpsey" wrote:

One way:

Public Sub try()
Range("A1").Value = Time
'rest of the macro
End Sub

In article ,
Nagesh wrote:

Hi All,

I'm generating reports using macros. I would like to Insert a time stamp
when the macro is run. Can you please let me know how?

I'm aware of =Now() to insert time stamp. But like to insert actual time
when the user runs the macro.

Thanks,
Nagesh



JE McGimpsey

Insert Time Stamp when macro is run
 
Hmm.. Doesn't here.

Another way:

Public Sub try()
With Range("A1")
.Value = Time
.NumberFormat = "00:00:00"
End With
'rest of macro
End Sub

In article ,
Nagesh wrote:

Your solution works, but the date is inserted as 1/1/1900..I have instead
used =now() instead of Time

Thanks for getting me going


"JE McGimpsey" wrote:

One way:

Public Sub try()
Range("A1").Value = Time
'rest of the macro
End Sub



All times are GMT +1. The time now is 02:55 AM.

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