Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with Date Macro/Function


Hey everyone. I know most of the basic stuff about Excel, but I have
never used Macros before and I believe that is what I need for this
particular problem.

What I need is some way that I can run a macro or whatever, and if I
run the macro it will update a field on the spreadsheet. But I don't
want it to update every time the user opens the spreadsheet, only if
they run the macro.

What I want the macro to display is the Year Month Day Hour Minute
Second of whatever date/time it is when the macro is ran. And I need
all of the values to be 2 digits. So if it was 2:33.54am January 1,
1994 and I ran the macro the field would be updated and say:
940101023354 formatted yymmddhhmmss

If anyone knows how to do this I would greatly appreciate some
instruction.

Thanks very much in advance.

Ryan M. Murphy


--
RyanMMurphy
------------------------------------------------------------------------
RyanMMurphy's Profile: http://www.excelforum.com/member.php...o&userid=33453
View this thread: http://www.excelforum.com/showthread...hreadid=532608

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Help with Date Macro/Function

Ryan,

So why not use "=Now()" and format the output to "yymmddhhmmss" (all
without the quotes)?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Help with Date Macro/Function

Sub DateMacro()
Worksheets("Sheet1").Range("A1").Value = Format(Now,"yymmddhhmmss")
End Sub

change the sheet and cell to suit.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"RyanMMurphy"
wrote in message
...

Hey everyone. I know most of the basic stuff about Excel, but I have
never used Macros before and I believe that is what I need for this
particular problem.

What I need is some way that I can run a macro or whatever, and if I
run the macro it will update a field on the spreadsheet. But I don't
want it to update every time the user opens the spreadsheet, only if
they run the macro.

What I want the macro to display is the Year Month Day Hour Minute
Second of whatever date/time it is when the macro is ran. And I need
all of the values to be 2 digits. So if it was 2:33.54am January 1,
1994 and I ran the macro the field would be updated and say:
940101023354 formatted yymmddhhmmss

If anyone knows how to do this I would greatly appreciate some
instruction.

Thanks very much in advance.

Ryan M. Murphy


--
RyanMMurphy
------------------------------------------------------------------------
RyanMMurphy's Profile:

http://www.excelforum.com/member.php...o&userid=33453
View this thread: http://www.excelforum.com/showthread...hreadid=532608



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Help with Date Macro/Function

Sub TimeStamp()
With ActiveCell
.Value = Now
.NumberFormat = "yymmddhhmmss"
End With
End Sub

HTH
--
AP

"RyanMMurphy" a
écrit dans le message de
...

Hey everyone. I know most of the basic stuff about Excel, but I have
never used Macros before and I believe that is what I need for this
particular problem.

What I need is some way that I can run a macro or whatever, and if I
run the macro it will update a field on the spreadsheet. But I don't
want it to update every time the user opens the spreadsheet, only if
they run the macro.

What I want the macro to display is the Year Month Day Hour Minute
Second of whatever date/time it is when the macro is ran. And I need
all of the values to be 2 digits. So if it was 2:33.54am January 1,
1994 and I ran the macro the field would be updated and say:
940101023354 formatted yymmddhhmmss

If anyone knows how to do this I would greatly appreciate some
instruction.

Thanks very much in advance.

Ryan M. Murphy


--
RyanMMurphy
------------------------------------------------------------------------
RyanMMurphy's Profile:

http://www.excelforum.com/member.php...o&userid=33453
View this thread: http://www.excelforum.com/showthread...hreadid=532608



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with Date Macro/Function


This enters the date & time into cell A1 of Sheet1,
Hope this is what your after.

Sub DateMacro()

Dim myNow As String

myNow = Format(Now(), "YYMMDDhhmmss")

With Sheets("Sheet1").Range("A1")
.NumberFormat = "@"
.Value = myNow
End With

End Sub

Pet

--
Peter8
-----------------------------------------------------------------------
Peter81's Profile: http://www.excelforum.com/member.php...fo&userid=2535
View this thread: http://www.excelforum.com/showthread.php?threadid=53260



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with Date Macro/Function


Thanks very much for the help everyone. I got exactly what I needed.


--
RyanMMurphy
------------------------------------------------------------------------
RyanMMurphy's Profile: http://www.excelforum.com/member.php...o&userid=33453
View this thread: http://www.excelforum.com/showthread...hreadid=532608

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with Date Macro/Function


If anyone is still checking this post. Another quick question. Is ther
a way to make this macro run when the spreadsheet is opened? The logi
behind it has changed a little bit. I got it working to meed th
changed requirements but if possible it would be great to have it ru
when the spreadsheet opens.

Thanks for any and all help.

Rya

--
RyanMMurph
-----------------------------------------------------------------------
RyanMMurphy's Profile: http://www.excelforum.com/member.php...fo&userid=3345
View this thread: http://www.excelforum.com/showthread.php?threadid=53260

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Help with Date Macro/Function

FROM THE VISUAL BASIC EDITOR. IN THE PROJECT PANE ON THE LEFT CLICK ON THIS
WORKBOOK (ASSUMING YOU ONLY HAVE ONE PROJECT OPEN). IN THE RIGHT HAND PANE
YOU SHOULD HAVE A COUPLE OF DROPDOWNS CHANGE THE FIRST FROM (GENERAL) TO
"WORKBOOK" AND THE SECOND TO "OPEN". PUT YOUR CODE IN WORKBOOK_OPEN SUB AND
THAT SHOULD DO IT.

"RyanMMurphy" wrote:


If anyone is still checking this post. Another quick question. Is there
a way to make this macro run when the spreadsheet is opened? The logic
behind it has changed a little bit. I got it working to meed the
changed requirements but if possible it would be great to have it run
when the spreadsheet opens.

Thanks for any and all help.

Ryan


--
RyanMMurphy
------------------------------------------------------------------------
RyanMMurphy's Profile: http://www.excelforum.com/member.php...o&userid=33453
View this thread: http://www.excelforum.com/showthread...hreadid=532608


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
How do I get a macro or excel function copy a value on date JeremyR. Excel Worksheet Functions 1 March 6th 09 12:53 AM
Is there a "last saved on date/user" macro/function for Excel 2003 Zliz Excel Discussion (Misc queries) 2 January 2nd 07 10:12 PM
Date Function formula that will return the date of a specific week Greg Excel Worksheet Functions 4 June 12th 06 05:07 PM
Calculating days between current date and a date in future NETWORKDAYS() function Faheem Khan Excel Worksheet Functions 2 February 10th 05 07:18 PM
Date Overdue function, Macro, or VBS Galsaba Excel Discussion (Misc queries) 5 January 14th 05 12:26 AM


All times are GMT +1. The time now is 12:22 PM.

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

About Us

"It's about Microsoft Excel"