Excel/VBA inconsistent date conversions

Trebor8484

Board Regular
Joined
Oct 27, 2018
Messages
69
Office Version
  1. 2013
Platform
  1. Windows
Hi all,

I have a column containing dates, some of which are text formatted dates and Excel prompts me that "This cell represents a date string represented with only 2 digits for the year". There are other cells within the column that are formatted as number. What I am trying to do is apply text to columns on the column which then correctly coverts the text dates to correct dates. For the cells that are already in number format though the dates will sometimes convert from UK to American format, so 03/08/2019 is is displayed as 08/03/2019. It seems hit and miss though, sometimes it converts it, sometimes it displays it correctly.

What I want to do is use VBA to convert the full column as I have some other code that merges multiple workbooks into one and some of these have dates provided in different formats, i.e. some as text and some as correct dates. Can anyone suggest a way to do this successfully were correct dates are ignored and text formatted dates are amended> The final output should have a fully formatted column of dates in UK format.

I have always used the below code and have never noticed this problem before.

VBA Code:
DstSheet.[C:C].TextToColumns , xlDelimited, , False, False, False, False, False, False
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
You can put a representative sample of your data in column C, where you show which dates do convert and which do not.
Use XL2BB tool to show sample, see my signature.
 
Upvote 0
From personal experience, I would say that dates usually convert fine with text to columns but I have noticed the following.

If you change the format of the cells before running text to columns then problems can occur.

If you add new dates to the end of the column then re-run text to columns and include dates that have previously been parsed (running text to columns more than once on all or part of the column) then problems can occur.
 
Upvote 0

Forum statistics

Threads
1,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

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.
Go back
Back
Top