ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Updating time made by macro in excel (https://www.excelbanter.com/excel-programming/403373-updating-time-made-macro-excel.html)

hjemmehososs

Updating time made by macro in excel
 
I have recorded a macro in excel. The macro includes current date and current
time which are pasted into two separate cells. I use ctrl+; and ctrl+: when
programming the macro.
When using the macro, the values of both date and time are constantly the
same as the date and time I made the macro.
How may the date and time be changed to the actual time when I use the macro?
Using the now() - function is not much help, as then all macros recorded
change to the actual date and time.

I used the program recorder.exe, and old -93-version earlier - but it does
not work with Vista.

Thankful if anyone can help me out here.
--
hjemmehososs

Carim[_2_]

Updating time made by macro in excel
 
Hi,

Use instructions :
Range("A1").Value = Date
Range("B1").Value = Time

HTH

FSt1

Updating time made by macro in excel
 
hi
if you did it on record then you lines of code should looks something like
this....
ActiveCell.FormulaR1C1 = "12/29/07"
ActiveCell.FormulaR1C1 = "1:59pm"
anything in quotes will be interpeted by vb as literal which is why it keeps
putting your old date and time in.
change to....
ActiveCell.FormulaR1C1 = Date
ActiveCell.FormulaR1C1 = Time

regards
FSt1

"hjemmehososs" wrote:

I have recorded a macro in excel. The macro includes current date and current
time which are pasted into two separate cells. I use ctrl+; and ctrl+: when
programming the macro.
When using the macro, the values of both date and time are constantly the
same as the date and time I made the macro.
How may the date and time be changed to the actual time when I use the macro?
Using the now() - function is not much help, as then all macros recorded
change to the actual date and time.

I used the program recorder.exe, and old -93-version earlier - but it does
not work with Vista.

Thankful if anyone can help me out here.
--
hjemmehososs


hjemmehososs

Updating time made by macro in excel
 
Thank you very much for your advice.
It was very helpful and made my day!
--
hjemmehososs


"FSt1" wrote:

hi
if you did it on record then you lines of code should looks something like
this....
ActiveCell.FormulaR1C1 = "12/29/07"
ActiveCell.FormulaR1C1 = "1:59pm"
anything in quotes will be interpeted by vb as literal which is why it keeps
putting your old date and time in.
change to....
ActiveCell.FormulaR1C1 = Date
ActiveCell.FormulaR1C1 = Time

regards
FSt1

"hjemmehososs" wrote:

I have recorded a macro in excel. The macro includes current date and current
time which are pasted into two separate cells. I use ctrl+; and ctrl+: when
programming the macro.
When using the macro, the values of both date and time are constantly the
same as the date and time I made the macro.
How may the date and time be changed to the actual time when I use the macro?
Using the now() - function is not much help, as then all macros recorded
change to the actual date and time.

I used the program recorder.exe, and old -93-version earlier - but it does
not work with Vista.

Thankful if anyone can help me out here.
--
hjemmehososs



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

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