Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 79
Default Macro for data and time

Hi

I have recently started to use Excel 2007 and have tried to create a macro
that records the date and time. I have recorded the key strokes ctrl ; and
space and ctrl shift ;

Unfortunately it just enters the date at the time I recorded the macro. I
would like to record just the key strokes so it puts in the date and time at
the time the macro is run. Is this possible? I am not a great expert at
visual basic but can normally fudge a solution! Any suggestion to do this?

Any help greatly appreciated

rexmann
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 535
Default Macro for data and time

Hi Rexmann,

Unfortunately it just enters the date at the time I recorded the macro. I
would like to record just the key strokes so it puts in the date and time at
the time the macro is run. Is this possible? I am not a great expert at
visual basic but can normally fudge a solution! Any suggestion to do this?


For the time, make sure the code within your macro is like this:

ActiveCell.Value = Time

and for the date:

ActiveCell.Value = Date

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default Macro for data and time

Try this.

Past the below code in Excel VBA Module and assign shortcut key for that.

Press ALT+F11 and go to Insert and click Module. And paste the below code.

Sub DateandTime()
ActiveCell = Now()
End Sub

After pasting the code close the VBA and press ALT+F8, the DateandTime Macro
will appear. Just select it and select Options and give your desired
keyboard button as shortcut key to run the macro.

If you want to show the cells including seconds just select the cells and
Goto Format and select custom and paste this format [$-409]m/d/yy h:mm:ss
AM/PM;@

If this post helps, Click Yes!

--------------------
(MS-Exl-Learner)
--------------------

"rexmann" wrote:

Hi

I have recently started to use Excel 2007 and have tried to create a macro
that records the date and time. I have recorded the key strokes ctrl ; and
space and ctrl shift ;

Unfortunately it just enters the date at the time I recorded the macro. I
would like to record just the key strokes so it puts in the date and time at
the time the macro is run. Is this possible? I am not a great expert at
visual basic but can normally fudge a solution! Any suggestion to do this?

Any help greatly appreciated

rexmann

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 79
Default Macro for data and time

Hi

Brilliant, worked a treat, thank you (plus the seconds bit is an added bonus)

Cheers Rexmann

"Ms-Exl-Learner" wrote:

Try this.

Past the below code in Excel VBA Module and assign shortcut key for that.

Press ALT+F11 and go to Insert and click Module. And paste the below code.

Sub DateandTime()
ActiveCell = Now()
End Sub

After pasting the code close the VBA and press ALT+F8, the DateandTime Macro
will appear. Just select it and select Options and give your desired
keyboard button as shortcut key to run the macro.

If you want to show the cells including seconds just select the cells and
Goto Format and select custom and paste this format [$-409]m/d/yy h:mm:ss
AM/PM;@

If this post helps, Click Yes!

--------------------
(MS-Exl-Learner)
--------------------

"rexmann" wrote:

Hi

I have recently started to use Excel 2007 and have tried to create a macro
that records the date and time. I have recorded the key strokes ctrl ; and
space and ctrl shift ;

Unfortunately it just enters the date at the time I recorded the macro. I
would like to record just the key strokes so it puts in the date and time at
the time the macro is run. Is this possible? I am not a great expert at
visual basic but can normally fudge a solution! Any suggestion to do this?

Any help greatly appreciated

rexmann

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
Macro / function text time to 24hr excel time passed midnight fortotaling hr's Russmaz Excel Worksheet Functions 2 March 6th 09 04:58 AM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
How do I get a macro in excel to look at different data each time zetty Excel Discussion (Misc queries) 3 February 7th 07 02:48 AM
time formatting and time categorizing (vlookup or data validation) MarianneR Excel Worksheet Functions 4 November 18th 04 03:24 PM
time formatting and time categorizing (vlookup or data validation) MarianneR Excel Worksheet Functions 0 November 18th 04 03:13 PM


All times are GMT +1. The time now is 10:04 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"