Glad it work, but I specified the range incorrectly, so you need to amend it to suit:This is what i was looking for, thanks a ton Akuini
thanks a lot Alex your formula is also perfect, but needed a vba code.
For Each c In Range("H8:M8") '<--amend to suit
yes that i did.Glad it work, but I specified the range incorrectly, so you need to amend it to suit:
VBA Code:For Each c In Range("H8:M8") '<--amend to suit
Hi AkuiniAnother option, with vba:
This will remove the time part, and keep the date only.
VBA Code:Sub TO_DATE1() Dim c As Range For Each c In Range("H8:M8") If Len(c) > 7 Then c = CDate(Left(c, 8)) Next Range("H8:BC8").NumberFormat = "dd-mm-yyyy" End Sub
1/07/22, 00:00 | 1/07/22, 01:00 | 1/07/22, 02:00 | 1/07/22, 03:00 |
24/06/22, 00:00 | 24/06/22, 01:00 | 24/06/22, 02:00 | 24/06/22, 03:00 | 24/06/22, 04:00 | 24/06/22, 05:00 |
[QUOTE]
If Len(c) > 7 Then c = CDate(Left(c, 8)) 'Run time error Type mismatch
[/QUOTE]
Sub TO_DATE2()
Dim c As Range, tx As String
For Each c In Range("H8:BC8")
tx = c.Value
If Mid(tx, 2, 1) = "/" Then tx = "0" & tx
If Len(tx) > 7 Then c = CDate(Left(tx, 8))
Next
Range("H8:BC8").NumberFormat = "dd-mm-yyyy"
End Sub
thanks a ton man, you are a life saver..Ok, try this one:
VBA Code:Sub TO_DATE2() Dim c As Range, tx As String For Each c In Range("H8:BC8") tx = c.Value If Mid(tx, 2, 1) = "/" Then tx = "0" & tx If Len(tx) > 7 Then c = CDate(Left(tx, 8)) Next Range("H8:BC8").NumberFormat = "dd-mm-yyyy" End Sub