ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with Date Macro/Function (https://www.excelbanter.com/excel-programming/358807-help-date-macro-function.html)

RyanMMurphy

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


Bob Phillips[_6_]

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




Art H

Help with Date Macro/Function
 
Ryan,

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


Peter81[_8_]

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


Ardus Petus

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




RyanMMurphy[_2_]

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


RyanMMurphy[_3_]

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


pete the greek

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




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

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