Help with formatting date

TonyF57

New Member
Joined
May 28, 2021
Messages
8
Office Version
  1. 2019
Platform
  1. Windows
I am importing data and the date is in the incorrect format and has a green triangle top left of each date cell.

It gives me the option to ignore error, change date format by converting XX to 19XX or convert XX to 2021

I can resolve it manually by selecting the column and changing format to xx21 but I'd like to do it via a macro.

The macro works up until the point where I select the error dropdown, presumably that is not recordable.

Is there an automatic way of doing this?

Tony

There can be up to 10,000 entries.

I am importing data and the date is in the incorrect format and has a green triangle top left of each date cell.

It gives me the option to ignore error, change date format by converting XX to 19XX or convert XX to 2021

I can resolve it manually by selecting the column and changing format to xx21 but I'd like to do it via a macro.

The macro works up until the point where I select the error dropdown, presumably that is not recordable.

Is there an automatic way of doing this?

Tony

There can be up to 10,000 entries.

Date Format.xlsx
B
130/04/21
230/04/21
330/04/21
430/04/21
530/04/21
Sheet1
 

Attachments

  • Date.jpg
    Date.jpg
    8.5 KB · Views: 5

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
As it is just a bad import so the better is to directly work on the import file rather than after the importation …​
 
Upvote 0
The Date would convert OK if your system has Regional Settings of International
Try Data Text to Columns
clear delimiters
Date use DMY
Specify where you want the result ( for my example I used B4)
Format to your preference

Date and Time 2021.xlsm
ABCDE
1
230/04/2130-Apr-2021Regional Settings International
3
430/04/212021-04-30
530/04/212021-04-30
630/04/212021-04-30
730/04/212021-04-30
8
11a
Cell Formulas
RangeFormula
B2B2=A2+0
 
Upvote 0
As it is just a bad import so the better is to directly work on the import file rather than after the importation …​

That's not an option unfortunately, the source won't even allow export of data, everything is copy and paste which is so tedious in this day and age.
 
Upvote 0
The Date would convert OK if your system has Regional Settings of International
Try Data Text to Columns
clear delimiters
Date use DMY
Specify where you want the result ( for my example I used B4)
Format to your preference

Date and Time 2021.xlsm
ABCDE
1
230/04/2130-Apr-2021Regional Settings International
3
430/04/212021-04-30
530/04/212021-04-30
630/04/212021-04-30
730/04/212021-04-30
8
11a
Cell Formulas
RangeFormula
B2B2=A2+0
Thanks Dave, my settings are UK, I've looked but don't see an international option.

I was hoping to not use a formula as it's another action, I was hoping to find a macro solution if at all possible.
 
Upvote 0
Quote "Thanks Dave, my settings are UK, I've looked but don't see an international option. " (1)
"I was hoping to not use a formula as it's another action, I was hoping to find a macro solution if at all possible." (2)

(1) UK is part of the International community that uses Regional Settings dd-mm-yy.
(2) It might be useful to know what the challenge is and then use VBA if necessary.

What is the length of the text in say cell A2?
Date and Time 2021.xlsm
ABC
230/04/2130-Apr-20218
11a
Cell Formulas
RangeFormula
B2B2=A2+0
C2C2=LEN(A2)

In Canada, we use both USA standard and International standard.

In the UK, the data that you showed should show proper dates.

Did you try coercing the text? Copy a blank cell and Paste Special Add.

Please post a sample of your data with the forum's tool XL2BB.
 
Upvote 0
If the date Windows Regional Settings is the same than the text dates column so just try a VBA codeline like Range.FormulaLocal = Range.Value2 …​
The other obvious way is to just convert the column via the easy Excel feature Text To Columns in the Data tab whatever manually or under VBA …​
 
Upvote 0
If the date Windows Regional Settings is the same than the text dates column so just try a VBA codeline like Range.FormulaLocal = Range.Value2 …​
The other obvious way is to just convert the column via the easy Excel feature Text To Columns in the Data tab whatever manually or under VBA …​
Thanks Marc,

Hadn't thought of Text To Columns as an option, selected the range, Delimited, Other forgot to specify the delimiter (/) it now appears to be correct looks good but unable to record it as a macro.

Not sure how I would try a vba codeline but at least I have a relatively easy solution now.

Thank you
 
Upvote 0
Quote "Thanks Dave, my settings are UK, I've looked but don't see an international option. " (1)
"I was hoping to not use a formula as it's another action, I was hoping to find a macro solution if at all possible." (2)

(1) UK is part of the International community that uses Regional Settings dd-mm-yy.
(2) It might be useful to know what the challenge is and then use VBA if necessary.

What is the length of the text in say cell A2?
Date and Time 2021.xlsm
ABC
230/04/2130-Apr-20218
11a
Cell Formulas
RangeFormula
B2B2=A2+0
C2C2=LEN(A2)

In Canada, we use both USA standard and International standard.

In the UK, the data that you showed should show proper dates.

Did you try coercing the text? Copy a blank cell and Paste Special Add.

Please post a sample of your data with the forum's tool XL2BB.
What is the length of the text in say cell A2?
Not sure what the {Range=...Range] relates too, beyond my brain capacity ;))

Thought I had posted a sample of the data in the first post but it appears to be an image, I will look into that and see if I can get it uploaded.
 
Upvote 0
Regarding to your reply to Marc

To use Text to Columns with Date issues

Open Text to Columns
move to Delimiters remove all checks
move to next then Date select DMY and select where to put result or change in place
press enter
 
Upvote 0

Forum statistics

Threads
1,215,212
Messages
6,123,653
Members
449,111
Latest member
ghennedy

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