Add 20 minutes to a time- end result has to be left as text format

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Good evening, I need to add one more time to my spread sheet. In Column D I have a time (24 hour clock) in a text format. This is so I can have numbers beginning with 0 and have no colons. Is it possible to come up with a VBA that will add 20 minutes to numbers that are listed in Column D and place the end result in Column E. I provided an image of a before and after short of worksheet "72 Hr". Naturally I'll need both Columns D and E to end up as a Text. Thank you,


Block to Dep.JPG
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Any reason why you can't just use normal time with a custom format of hhmm (no colon)?
If that will work, I don't know if that involves changing the other into a custom format. It took up to three weeks to get me this far, and this is the final macro. There are about 40 macros in total and about four of them involve the time. Having said that I thought maybe there was something that will change column D very briefly to a custom format than update Column E then change everything back to text. So much work has went into this, I don't want to mess anything up for it works perfect now. I just want to add that time. It is a must the 0s are visible on times before 1000. Thank you,
 
Upvote 0
Any reason why you can't just use normal time with a custom format of hhmm (no colon)?
Hello I have the time format in a custom at this point, see photo. I would then need to add 20 minutes and have that result in Column E. Then I I can use the formula below but I'll need to include E in addition to Column D. I think this will work. Thank you,


Time.JPG



VBA Code:
Sub twenty_four_hour_Clock()
 With Range("D1", Range("D" & Rows.Count).End(xlUp))
.NumberFormat = "@"
.Value = Evaluate(Replace("if(@="""","""",if(isnumber(@),text(mod(@,1),""hhmm""),@))", "@", .Address))
End With
End Sub
 
Upvote 0
Any reason why you can't just use normal time with a custom format of hhmm (no colon)?
I know that
Excel Formula:
=D7+20/1440
does work, but I just need that translated to a VBA with the results posted in Column E, and only for those with a time in Column D.
 
Upvote 0
If you want to add the 20 minutes to the code in post 4 then you should be able to do it with a small edit to the currently evaluated formula, mod(@+20/1440,1)
 
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,565
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top