#1   Report Post  
Michael Link
 
Posts: n/a
Default Date/Time Macro

I guess this is part 2 of a query I started below. I need a macro that =
will=20
enter both the current date and time into the active cell whenever it is =
run.=20
Since this is for a workbook shared across a network, the information =
needs=20
to remain unchanged in the cell even if the macro is run for another =
active=20
cell by someone else on the network.

Help! I've recorded or written very few macros, and unfortunately I =
need to=20
have this one running as soon as possible. Thanks in advance for your =
help,=20
and thanks to the folks who offered assistance to a related date/time =
query=20
earlier today.
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Sub DateAndTime()
With ActiveCell
.Value = Now
.NumberFormat = "dd mm yyyy hh:mm:ss"
End With
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Michael Link" wrote in message
...
I guess this is part 2 of a query I started below. I need a macro that will
enter both the current date and time into the active cell whenever it is
run.
Since this is for a workbook shared across a network, the information needs
to remain unchanged in the cell even if the macro is run for another active
cell by someone else on the network.

Help! I've recorded or written very few macros, and unfortunately I need to
have this one running as soon as possible. Thanks in advance for your help,
and thanks to the folks who offered assistance to a related date/time query
earlier today.


  #3   Report Post  
 
Posts: n/a
Default

Very cool--you know, even though it's such a small routine, I could =
never=20
have come up with it. Thanks a lot! I wonder--is it possible to have =
the=20
macro return the time so that it isn't in military time, but uses an =
"AM" or=20
"PM" indicator instead? (And I can't tell--is there one space bar space =

between the date and time so that it conforms with Excel date/time =
format=20
and can be used for calculations?) The folks who will use this could of=20
course do the calculation themselves, but I want the info to be as =
quickly=20
absorbed as possible.

Again--very cool. Thank you so much!
-----Original Message-----
Sub DateAndTime()
With ActiveCell
.Value =3D Now
.NumberFormat =3D "dd mm yyyy hh:mm:ss"
End With
End Sub


--=20

HTH

RP
(remove nothere from the email address if mailing direct)


"Michael Link" wrote in message
...
I guess this is part 2 of a query I started below. I need a macro that =

will
enter both the current date and time into the active cell whenever it =

is
run.
Since this is for a workbook shared across a network, the information=20

needs
to remain unchanged in the cell even if the macro is run for another =

active
cell by someone else on the network.

Help! I've recorded or written very few macros, and unfortunately I =

need to
have this one running as soon as possible. Thanks in advance for your=20

help,
and thanks to the folks who offered assistance to a related date/time=20

query
earlier today.


.

  #4   Report Post  
 
Posts: n/a
Default

Bob Phillips will probably answer your question better but
you could always use the =NOW() function or =DATE() and
=TIME() functions and just write your macro to
recalculate (F9)
Go to the cell(s) with the fomula(e) and copy
And Go to a destination cell and paste special values.
You can formet the destination cells any way you want

-----Original Message-----
Very cool--you know, even though it's such a small

routine, I could never
have come up with it. Thanks a lot! I wonder--is it

possible to have the
macro return the time so that it isn't in military time,

but uses an "AM" or
"PM" indicator instead? (And I can't tell--is there one

space bar space
between the date and time so that it conforms with Excel

date/time format
and can be used for calculations?) The folks who will use

this could of
course do the calculation themselves, but I want the info

to be as quickly
absorbed as possible.

Again--very cool. Thank you so much!
-----Original Message-----
Sub DateAndTime()
With ActiveCell
.Value = Now
.NumberFormat = "dd mm yyyy hh:mm:ss"
End With
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Michael Link" wrote in

message
...
I guess this is part 2 of a query I started below. I

need a macro that will
enter both the current date and time into the active

cell whenever it is
run.
Since this is for a workbook shared across a network,

the information
needs
to remain unchanged in the cell even if the macro is run

for another active
cell by someone else on the network.

Help! I've recorded or written very few macros, and

unfortunately I need to
have this one running as soon as possible. Thanks in

advance for your
help,
and thanks to the folks who offered assistance to a

related date/time
query
earlier today.


.

.

  #5   Report Post  
 
Posts: n/a
Default

That last one I sent doesn't work, but you can put =NOW()
in one cell, recalculate, copy, paste values in two cells,
with one formatted as date, and the other formatted as
time.
If you're just pasting values, the destination cells will
hold their formatting.


-----Original Message-----
Very cool--you know, even though it's such a small

routine, I could never
have come up with it. Thanks a lot! I wonder--is it

possible to have the
macro return the time so that it isn't in military time,

but uses an "AM" or
"PM" indicator instead? (And I can't tell--is there one

space bar space
between the date and time so that it conforms with Excel

date/time format
and can be used for calculations?) The folks who will use

this could of
course do the calculation themselves, but I want the info

to be as quickly
absorbed as possible.

Again--very cool. Thank you so much!
-----Original Message-----
Sub DateAndTime()
With ActiveCell
.Value = Now
.NumberFormat = "dd mm yyyy hh:mm:ss"
End With
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Michael Link" wrote in

message
...
I guess this is part 2 of a query I started below. I

need a macro that will
enter both the current date and time into the active

cell whenever it is
run.
Since this is for a workbook shared across a network,

the information
needs
to remain unchanged in the cell even if the macro is run

for another active
cell by someone else on the network.

Help! I've recorded or written very few macros, and

unfortunately I need to
have this one running as soon as possible. Thanks in

advance for your
help,
and thanks to the folks who offered assistance to a

related date/time
query
earlier today.


.

.



  #6   Report Post  
Bob Phillips
 
Posts: n/a
Default

Michael,

The format is just that, a format, so it can be changed in many ways,
nothing to do with keeping it as a number, but is simply a matter of how it
looks. But, it is still a number, so it can be used for calculations as you
need.

The new macro would just be

Sub DateAndTime()
With ActiveCell
.Value = Now
.NumberFormat = "dd mmm yyyy hh:mm AM/PM"
End With
End Sub

Note that I added an m in the month format so it shows as Feb not 02.

--

HTH

RP
(remove nothere from the email address if mailing direct)


wrote in message
...
Very cool--you know, even though it's such a small routine, I could never
have come up with it. Thanks a lot! I wonder--is it possible to have the
macro return the time so that it isn't in military time, but uses an "AM" or
"PM" indicator instead? (And I can't tell--is there one space bar space
between the date and time so that it conforms with Excel date/time format
and can be used for calculations?) The folks who will use this could of
course do the calculation themselves, but I want the info to be as quickly
absorbed as possible.

Again--very cool. Thank you so much!
-----Original Message-----
Sub DateAndTime()
With ActiveCell
.Value = Now
.NumberFormat = "dd mm yyyy hh:mm:ss"
End With
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Michael Link" wrote in message
...
I guess this is part 2 of a query I started below. I need a macro that will
enter both the current date and time into the active cell whenever it is
run.
Since this is for a workbook shared across a network, the information

needs
to remain unchanged in the cell even if the macro is run for another active
cell by someone else on the network.

Help! I've recorded or written very few macros, and unfortunately I need

to
have this one running as soon as possible. Thanks in advance for your

help,
and thanks to the folks who offered assistance to a related date/time

query
earlier today.


.



  #7   Report Post  
Dave Peterson
 
Posts: n/a
Default

You have another (similar) suggestion at your other thread.

Michael Link wrote:

I guess this is part 2 of a query I started below. I need a macro that will
enter both the current date and time into the active cell whenever it is run.
Since this is for a workbook shared across a network, the information needs
to remain unchanged in the cell even if the macro is run for another active
cell by someone else on the network.

Help! I've recorded or written very few macros, and unfortunately I need to
have this one running as soon as possible. Thanks in advance for your help,
and thanks to the folks who offered assistance to a related date/time query
earlier today.


--

Dave Peterson
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
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM
Can't get simple macro to run Abi Excel Worksheet Functions 5 January 12th 05 07:37 PM
Help with macro formula and variable Huge project Excel Worksheet Functions 0 December 28th 04 01:27 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM
Macro Formula revision? Mark Excel Worksheet Functions 1 November 28th 04 01:43 AM


All times are GMT +1. The time now is 06:23 AM.

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"