ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to change date cell by specified interval (https://www.excelbanter.com/excel-programming/406449-macro-change-date-cell-specified-interval.html)

Adam

Macro to change date cell by specified interval
 
I would like to create a macro in Excel that when executed adds or subtracts
a user specified interval of time in minutes. I would like two cells: one
with the date and the other with the interval, for example 10 minutes. When
the user executes the macro, I would like to see the date cell update. So if
the date cell was 2/12/08 1:00PM, the interval cell was 10 and you executed
the macro, the date cell updates to 2/12/08 1:10PM. Then if the macro is
executed again it would add another 10 minutes to and make the date 2/12/08
1:20PM. How would I go about achieving this. I have tried the DateAdd
function, but it only works for one execution. I want it to update and add
another 10 for the next execution.

joel

Macro to change date cell by specified interval
 
Range("A1") = Range("A1") + TimeSerial(0, 10, 0)

timeserial parameters are hours, minutes, seconds

"Adam" wrote:

I would like to create a macro in Excel that when executed adds or subtracts
a user specified interval of time in minutes. I would like two cells: one
with the date and the other with the interval, for example 10 minutes. When
the user executes the macro, I would like to see the date cell update. So if
the date cell was 2/12/08 1:00PM, the interval cell was 10 and you executed
the macro, the date cell updates to 2/12/08 1:10PM. Then if the macro is
executed again it would add another 10 minutes to and make the date 2/12/08
1:20PM. How would I go about achieving this. I have tried the DateAdd
function, but it only works for one execution. I want it to update and add
another 10 for the next execution.



All times are GMT +1. The time now is 05:33 AM.

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