#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Time Stamp

Hello,
I have created a time stamp macro. A very simple one liner.

609140048 ActiveCell.Value = Format(Now(), "yymmddhhmm")
060914_0049 ActiveCell.Value = Format(Now(), "yymmdd_hhmm")
609140050 ActiveCell.Value = CStr(Format(Now(),
"yymmddhhmm"))

These are three different lines I have tried. I want it to be flush
left (text) and to have
the leading zero and as in the middle one but I don't want the
underscore or gap as
in the other ones. How can I get the best of both worlds?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Time Stamp

Sub test()

With ActiveCell
.NumberFormat = "@"
.Value = Format(Now(), "yymmddhhmm")
End With

End Sub

RBS


"John Pierce" wrote in message
oups.com...
Hello,
I have created a time stamp macro. A very simple one liner.

609140048 ActiveCell.Value = Format(Now(), "yymmddhhmm")
060914_0049 ActiveCell.Value = Format(Now(), "yymmdd_hhmm")
609140050 ActiveCell.Value = CStr(Format(Now(),
"yymmddhhmm"))

These are three different lines I have tried. I want it to be flush
left (text) and to have
the leading zero and as in the middle one but I don't want the
underscore or gap as
in the other ones. How can I get the best of both worlds?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Time Stamp

Thanks RB, that looks good, except for one itty-bitty problem.
In Excel 2003 it causes one of those usually-very-helpful
but sometimes-annoying error flags - in this case telling
me what I already know - that "The number in this cell is
formatted as text or is preceded by an apostrophe." Is
there anyway to programmatically prevent this, some
built-in error-checking. I tried recording the steps
involved in opening the message and selecting
"Ignore error" but nothing was recorded.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Time Stamp

Try:

Sub test()

Application.DisplayAlerts = False

With ActiveCell
.NumberFormat = "@"
.Value = Format(Now(), "yymmddhhmm")
End With

Application.DisplayAlerts = True

End Sub


RBS

"John Pierce" wrote in message
oups.com...
Thanks RB, that looks good, except for one itty-bitty problem.
In Excel 2003 it causes one of those usually-very-helpful
but sometimes-annoying error flags - in this case telling
me what I already know - that "The number in this cell is
formatted as text or is preceded by an apostrophe." Is
there anyway to programmatically prevent this, some
built-in error-checking. I tried recording the steps
involved in opening the message and selecting
"Ignore error" but nothing was recorded.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Time Stamp

Nice try but that didn't get it. Perhaps because the error
isn't caused by VBA but is on the spread sheet.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Time Stamp Sara Excel Worksheet Functions 1 February 5th 09 02:32 PM
time stamp Bally Excel Worksheet Functions 2 April 9th 08 07:40 PM
Time Stamp FARAZ QURESHI Excel Discussion (Misc queries) 8 January 8th 07 11:51 PM
time stamp a cell that doesn,t change when time stamping another RC Excel Programming 5 October 13th 05 02:52 AM
Time Stamp Darren[_3_] Excel Programming 0 July 15th 03 05:13 AM


All times are GMT +1. The time now is 04:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"