Edit: VBA code now is working. Was just and .currentregion that messed it up for me
I have an issue, that is hopefully just some silly mistake from myside. I have a dataset that I get at least once a day with the dates not recognised as date, but as normal text. I would like to have this column changed to date with a VBA macro. The code I have written now, just gives me an error message, and I can not figure out what is wrong.
This is how the file looks, I could not figure out how to attach the file...
And here is my code
Sub Test()
Dim rg As Range
Set rg = Range("B2:B4")
rg.TextToColumns Destination:=Range("B2:B5"), ConsecutiveDelimiter:=True, DataType:=xlDelimited, Space:=True, FieldInfo:=Array(Array(1, 5))
End Sub
Any suggestion what might be wrong with the code or how I can make it work? The date format is YMD when I do this in the Text to Columns in excel itself. This is a part of a bigger VBA, so it would be much easier to do it as a VBA than to do it manually every time I need it.