extract date from a line with texts and numbers

Naresha

New Member
Joined
Jan 20, 2022
Messages
7
Office Version
  1. 2019
Platform
  1. Windows
Good afternoon!

I wonder if there is a way to extract date from the below line, numbers in red is the date (ie 18/10) that needs to be extracted and numbers in yellow are variables that differ in each line but the texts in each line remains the same. Please Help!

Elavon Financial S EMS589101823113401

TIA! :)
 
I am thinking that maybe you need to adjust a formula, and didn't do it quite right, because it works for me.

Can you confirm what columns you actual data is in, and what row the data starts on?
What cell are you putting this formula in?

Are you absolutely sure the values in the first column are valid date entries, and not dates entered as text?
You can check easily with a formula. Let's say that your first date is in cell A2. Then pick any blank cell and enter this formula and see what it returns:
=ISNUMBER(A2)
If it returns TRUE, you have a valid date. If it returns FALSE, you do not.

Also, are there any leading spaces at the beginning of your Descriptions?
If your first "Elavon" description is in cell B3, enter this formula in a blank cell and tell me what it returns:
=MID(B3,26,4)
excel copy.xlsx
ABCDEFG
1TransactiondateDescriptionFormula cells
212/04/2021Journal - Credit Card (33061) - 12/04/2021TRUE
313/04/2021Elavon Financial S EMS39704122254340109/05/2024not picking correct date3970
413/04/2021Journal - Credit Card (33061) - 13/04/2021
514/04/2021Elavon Financial S EMS39804132242340119/05/2024not picking correct date
614/04/2021Elavon Financial S EMS39304132306340230/03/2024not picking correct date
714/04/2021Journal - Credit Card (33061) - 14/04/2021
815/04/2021Elavon Financial S EMS39404142241340209/04/2024not picking correct date
915/04/2021Journal - Credit Card (33061) - 15/04/2021
1016/04/2021Elavon Financial S EMS40004152330340131/03/2024not picking correct date
11
12
13
14
15
16
Sheet2
Cell Formulas
RangeFormula
E2E2=ISNUMBER(A2)
E3E3=MID(B3,26,4)
C2:C10C2=IF(LEFT(B2,7)="journal",A2,DATE(YEAR(A2),MID(B2,26,2),MID(B2,28,2)))
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I am thinking that maybe you need to adjust a formula, and didn't do it quite right, because it works for me.

Can you confirm what columns you actual data is in, and what row the data starts on?
What cell are you putting this formula in?

Are you absolutely sure the values in the first column are valid date entries, and not dates entered as text?
You can check easily with a formula. Let's say that your first date is in cell A2. Then pick any blank cell and enter this formula and see what it returns:
=ISNUMBER(A2)
If it returns TRUE, you have a valid date. If it returns FALSE, you do not.

Also, are there any leading spaces at the beginning of your Descriptions?
If your first "Elavon" description is in cell B3, enter this formula in a blank cell and tell me what it returns:
=MID(B3,26,4)
Hi Joe,

I have tried to upload a mini-sheet for this working, hope this helps to figure out the error.

regards,
Naresha
 
Upvote 0
A ha! This is what happens when we are not provided accurate examples. Compare the last image you posted to the previous ones.
This current one show multiple spaces in the string before the "EMS..." part. Your previous ones only show single spaces. I think copy/pasting directly gets rid of mutliple spaces between items, which is why it it typically not a good tool to post sample data.

So there are three extra spaces that need to be accounted for in the formula, i.e.
=IF(LEFT(B2,7)="Journal",A2,DATE(YEAR(A2),MID(B2,29,2),MID(B2,31,2)))
 
Upvote 0
Solution
A ha! This is what happens when we are not provided accurate examples. Compare the last image you posted to the previous ones.
This current one show multiple spaces in the string before the "EMS..." part. Your previous ones only show single spaces. I think copy/pasting directly gets rid of mutliple spaces between items, which is why it it typically not a good tool to post sample data.

So there are three extra spaces that need to be accounted for in the formula, i.e.
=IF(LEFT(B2,7)="Journal",A2,DATE(YEAR(A2),MID(B2,29,2),MID(B2,31,2)))
Yay, this works! thank you so much Joe.. you are indeed a genius :)
And my apologies for not providing accurate examples in first place but I appreciate your patience and now can see how quickly I can finish my task using your formula.x
 
Upvote 0
You are welcome.
Glad we got it all sorted out and working for you!
:)
 
Upvote 0

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

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