VBA convert d.hh:mm:ss to hh:mm:ss

adryy_yy

New Member
Joined
Mar 12, 2018
Messages
6
Hello,

I'm new here and I need your help because I understand something Excel but VBA I don't understand anything.
So, if you can help me I say thanks so much.

And then, I have a sheet Excel with values in next format: "dd.hh:mm:ss". I would need to convert to "hh:mm:ss", but on VBA. Could you help me?

123m.jpg


Thanks
 
These code is just applicable to d.hh:mm:ss but in column there are d.hh:mm:ss and hh:mm:ss and I need apply in all cells of the column. ;)

Try this addition to also convert those time values without a day element to Excel times.

Rich (BB code):
Sub MyReplace()
With Sheets("Sheet1").Range("D2:D629")
  .Replace What:=".", Replacement:="Jan 1900 ", LookAt:=xlPart, SearchFormat:=False, ReplaceFormat:=False
  .TextToColumns DataType:=xlDelimited, TextQualifier:=xlNone, FieldInfo:=Array(1, 1)
  .NumberFormat = "[hh]:mm:ss"
End With
End Sub
 
Last edited:
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Try this addition to also convert those time values without a day element to Excel times.

Rich (BB code):
Sub MyReplace()
With Sheets("Sheet1").Range("D2:D629")
  .Replace What:=".", Replacement:="Jan 1900 ", LookAt:=xlPart, SearchFormat:=False, ReplaceFormat:=False
  .TextToColumns DataType:=xlDelimited, TextQualifier:=xlNone, FieldInfo:=Array(1, 1)
  .NumberFormat = "[hh]:mm:ss"
End With
End Sub

Perfect FormR... :D

hhhhmmmmm... I guess I say you "hello" again... :D
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,022
Latest member
RobertV1609

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