You could try splitting into a DateSerial
:
Sub Test()
Dim r As Range
Set r = Sheet1.Range("B10")
r = DateSerial(Split(r, ".")(2), Split(r, ".")(1), Split(r, ".")(0))
r.NumberFormat = "dd/mm/yyyy"
End Sub
Split returns a zero-based, one-dimensional array containing a specified number of substrings..
What this means in plain English is that it takes your text string of 03.07.18
and splits it into three parts using the .
.
So you end up with 03
, 07
and 18
within an array.
It might be easier to read as:
v = Split(r, ".")
r = DateSerial(v(2), v(1), v(0))
DateSerial
takes three numbers (year, month and day) and returns a date. The three parts of the Split are passed into this to create the date.
To process on a number of cells use:
Sub formatfixer()
Dim r As Range
For Each r In Range("H5:H120")
r = DateSerial(Split(r, ".")(2), Split(r, ".")(1), Split(r, ".")(0))
r.NumberFormat = "dd/mm/yyyy"
Next r
End Sub