Hi All,
I have a data import that includes the date as part of a string in one cell (example: 20221229 Rotator Test Protocol FLM2314, where 2022 is ""yyyy", 12 is "mm" and 29 is "dd"). I want to extract the date from the string and format it as expected for my Swiss company (yyyy.mm.dd). It must be done in VBA, as this string is part of a data importation, and should follow the rest of the script. I tried various approaches, including:
This is being interpreted as 1906.05.02, but the expected date is 2022.12.18.
The next approach was to try a formula, where I tried to extract the date using the Concatenate, Left and Mid functions (which, by the way, is working in the Formula bar - with the direct cell references of course):
...but in this case VBA doesn't like the "." in the equation - I get a "expected - end of statement" error.
can anyone think of another way?
I have a data import that includes the date as part of a string in one cell (example: 20221229 Rotator Test Protocol FLM2314, where 2022 is ""yyyy", 12 is "mm" and 29 is "dd"). I want to extract the date from the string and format it as expected for my Swiss company (yyyy.mm.dd). It must be done in VBA, as this string is part of a data importation, and should follow the rest of the script. I tried various approaches, including:
VBA Code:
Range("A" & lrow) = Format(Left(shNew.Range("H1"), 8), "yyyy.mm.dd") 'sets date
The next approach was to try a formula, where I tried to extract the date using the Concatenate, Left and Mid functions (which, by the way, is working in the Formula bar - with the direct cell references of course):
VBA Code:
Range("A" & lrow).Formula = "=CONCATENATE(LEFT(shNew.Range("H1");4);".";MID(shNew.Range("H1");5;2);".";MID(shNew.Range("H1");7;2))"
can anyone think of another way?