Data dump time value challange

MarkCBB

Active Member
Joined
Apr 12, 2010
Messages
497
Hi there,

I have a database that is downloaded, however some of the time values are not correct:

here is a sample:
0 7:37:26 PM
0 9:41:43 PM
0 9:50:13 PM
0 9:40:30 PM
0 9:42:45 PM
0 9:44:45 PM
0 9:45:15 PM
0 9:46:01 PM
0 9:47:01 PM
0 9:47:31 AM
0 9:49:31 PM
12:01:55 AM
04:51:55 PM
11:27:30 AM

Does anyone know why there are leading zeros?

Currently I am using the following formula to correct the entries
=TEXT(SUBSTITUTE(C17179,"0 ",""),"HH")

However I would prefer this to be a VBA solution, can anyone assist me?

the column in question is "C"

Thanks
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Code:
Sub Strip_Leading_Zeros()
    
    Dim i As Integer
    
    Application.ScreenUpdating = False
    With Columns("C:C")
    
        For i = 1 To 12
            .Replace What:="0 " & i, Replacement:=i, LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
        Next i
        
        .NumberFormat = "HH"
        
    End With
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,493
Messages
6,125,134
Members
449,206
Latest member
burgsrus

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