ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to get the time stamp in VBA for EXCEL (https://www.excelbanter.com/excel-programming/274377-how-get-time-stamp-vba-excel.html)

Ji Wenke[_2_]

How to get the time stamp in VBA for EXCEL
 
I want to record current time (Hour-Minutes-Second) in
VBA.How to accomplish with VB code,use what system
function call

Rocky McKinley

How to get the time stamp in VBA for EXCEL
 
Hi Ji,
Try this,

Sub TimeStamper()
Range("A1").Value = Now
Range("A1").NumberFormat = "H:MM AM/PM"
End Sub

Regards, Rocky McKinley


"Ji Wenke" wrote in message
...
I want to record current time (Hour-Minutes-Second) in
VBA.How to accomplish with VB code,use what system
function call




Michael Bednarek

How to get the time stamp in VBA for EXCEL
 
On Wed, 13 Aug 2003 20:24:04 -0700, "Ji Wenke"
wrote in microsoft.public.excel.programming:

I want to record current time (Hour-Minutes-Second) in
VBA.How to accomplish with VB code,use what system
function call


I probably misunderstand the question, but doesn't:
Hour(Now) & "-" & Minute(Now) & "-" & Second(Now)
work for you?
(Nit pick: the above might give unexpected results when its execution
straddles midnight.)

--
Michael Bednarek, IT Manager, Tactical Global Management
Waterfront Pl, Brisbane 4000, Australia. "POST NO BILLS"
http://mcmbednarek.tripod.com/

Rocky McKinley

How to get the time stamp in VBA for EXCEL
 
Hi Ji,
Oops should have included ":SS" as below,

Sub TimeStamper()
Range("A1").Value = Now
Range("A1").NumberFormat = "H:MM:SS AM/PM"
End Sub

Regards, Rocky McKinley


"Ji Wenke" wrote in message
...
I want to record current time (Hour-Minutes-Second) in
VBA.How to accomplish with VB code,use what system
function call







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

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