Excel/VBA inconsistent date conversions

Trebor8484

Board Regular
Joined
Oct 27, 2018
Messages
57
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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,779
Office Version
  1. 2007
Platform
  1. Windows
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.
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
12,921
Office Version
  1. 365
Platform
  1. Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,132,803
Messages
5,655,388
Members
418,195
Latest member
LabraLime

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
Top