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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
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,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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