SOLVED

macro recording for recording and updating hour and minutes data to the current time

Copper Contributor

Hello Microsoft Tech community,

I have attached a screenshot, if I press the Enter data button it should add the hours and minutes values that are entered in the assigned cells to the current time cell and next time the user get another option to enter new set of values of hours and minutes and again when the button is pressed it should update the current time which was lastly updated, so that every time when a person enters a new set of hours and minutes he can see the last updated time.  

For ex-: current time is 11:00AM and if I enter 2 in hour and 30 in minutes and press enter data it should update to 1:30Pm and again if I enter 1 in hour and 30 in minutes and press enter data it should be 3:00Pm and so on.

Is it possible to perform in excel, I hope I am clear with what I want to achieve??

If anyone could help me with this would be a great help.

 

Thank you.

8 Replies

You can do it without you need use a VBA, but as you request it using vba...

CellWithHours and CellWithMinutes are those ones where you input manually the Hours and the minutes.

StartDate is the cell reference you use on your spreadsheet.

Remember to change all of these variable names to the actual address of the cell.

 

YourOutputWillBe=DateAdd("h", CellWithHours, StartDate) + DateAdd("n", CellWithMinutes, StartDate)

@Juliano-Petrukio 

thank you for the reply.
I tried using the formula but it dint work as expected, I guess there is something wrong in my syntax that I have used.
In the attachment I expected the time to increase by 2hours and 30 minutes but it is showing 12:30Pm, also I want the current date to change to next date once the time crosses 12:00Am.
Can you please help me with the syntax based on the file I have shared. It would be really helpful.

 

Thank you.

Takes more time for us to understand your snapshots. I would suggest you post some sample file.

@Juliano-Petrukio oh ok, I am attaching one here. Please have a look.

 

 

Thank you.

best response confirmed by UG_1180 (Copper Contributor)
Solution

@UG_1180 

Range("E6").Value = Range("B6") + TimeSerial(Range("E10").Value, Range("E11").Value, 0)

 

If it worked for you, dont forget to flag it as solved.

Remember that hitting the like button is less costly than buying me a coffee.

 

1thank you guys so much take a picture of my work picture a camera a camera camera camera camera

smi Daisy Liangthankthank youthank you so much I said lainDaisy PeytonCaden CadenEnglish so much so much my Chanel and Mason Mason C Mason's taking you guys so much thank you for the book I see you guys tomorrow morning I-85 at 8:30 I-85 845if he has so much as you guys next videofamous tube kids famous tube kids Batman suit kids famous to get famous two kids Batman suitcasessis vs. bro Ronald sis versus bro versus sis versus brocall Mike by Mike by Mike and MikeElsa and Anna Elsa and Anna for school tomorrow on Thursday at 8:45 at 8:30 thank you guys so much I'll see you guys tomorrow have a good night TV thank you guys so much I hope you guys have a great weekend if you're free on Friday thank you guys so much have a good weekend thank you so much you're the best one in the whole wide world by Melissa Ramsey tomorrow at 7 I'm miserable around by miserable well Daisy by Daisy Daisy Daisy Daisy and land land land land land land so much power we have a good day as yes Mom

  1.  

@Juliano-Petrukio 

Yes thank you so much this is what I was expecting.

One more thing if you can help to do would be great is to update the date as well as soon as the time crosses 12:00Am with reference to the current date.

 

For ex-: if the start time is 11:00Pm and start date is 1st Jan'21 and I want to update 10 hours and 30 minutes which means it goes to the next day 09:30AM on 2nd Jan'21 so the current date should display 02-01-2021.  

 

Thank You.

1 best response

Accepted Solutions
best response confirmed by UG_1180 (Copper Contributor)
Solution

@UG_1180 

Range("E6").Value = Range("B6") + TimeSerial(Range("E10").Value, Range("E11").Value, 0)

 

If it worked for you, dont forget to flag it as solved.

Remember that hitting the like button is less costly than buying me a coffee.

 

View solution in original post