I have been doing this a while but I have no idea what you mean. Currently the string value in in a variable called strTemp.
I have thought about using something like your formula but it will always assume a two digit month and two digit day.
B2: =DATE(LEFT(A2, 4), MID(A2, 6, 2), MID(A2, 9, 2)) + RIGHT(A2, 5)
The formula returns an Excel date/time value. You can format it however you like.
In VBA,
Code:
Dim s As String
Dim t As Date
s = Range("A2").Value2
t = DateSerial(Left(s, 4), Mid(s, 6, 2), Mid(s, 9, 2)) + TimeValue(Right(s, 5))
Debug.Print Format(t, "dd mmm yyyy hh:mm")
For what's it's worth, I copied that 'date' into a worksheet, copied it down, loaded it into PowerQuery and the values was automatically converted to date/time.
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.