Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro / function text time to 24hr excel time passed midnight fortotaling hr's | Excel Worksheet Functions | |||
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 | Excel Discussion (Misc queries) | |||
How do I get a macro in excel to look at different data each time | Excel Discussion (Misc queries) | |||
time formatting and time categorizing (vlookup or data validation) | Excel Worksheet Functions | |||
time formatting and time categorizing (vlookup or data validation) | Excel Worksheet Functions |