Formula extract help

John44

Board Regular
Joined
Oct 1, 2014
Messages
60
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a whole list of entries like this. I need to pull out the job reference i.e. the J code. As the J code can vary from 5 to 7 characters then I can't use the FIND and MID to pull out the entire ref sometimes. Also, it pulls out descriptions for non job entries like ' - June' which I don't need. I need it to start at the J, determine it's a value after the J and then return up to the space before the dash after the J code. Does that make sense?

Can anyone help?

Thanks

John



1737036239962.png
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
I thought of that but the data will be dropped in more than once and will change rows i.e. it's a dynamic usable spreadsheet
 
Upvote 0
Try:
Book4
AB
1Job CodeDescription
2 GoDaddy - July Bill
3J123GoDaddy - July Bill - John - J123 - Joker
4J000063Fuel card - Part 2/5, FUEL CARD inv. 9003230422, date: 15/05/2022 - J000063 - Marine View, Fleetwood
5J129PayByPhone Parking - Premier House; 07/03/2024; 6490 - J129
6J132KaydeeSayfa - PO5598, Church Road, Crosby, 1st retention - J132
Sheet3
Cell Formulas
RangeFormula
A2:A6A2=LET(t,TEXTAFTER(TEXTSPLIT(B2," "),"J"),CONCAT(IF(ISNUMBER(--t),"J"&t,"")))
 
Upvote 0
Wow! That nearly works 100% thank you. It falls down on these types. Where the job number is manually typed in twice and what ever J9 is. Looks like something else. I don't have familiarity with these guys enough.

Job CodeJob NameDescription
J105J105#N/ADrive Card Europe - J105 (GEM Foston) - J105
J9-1#N/AInterest on loan and HP loan agreements - Interest (J9-1 LE69 LHR)
 
Upvote 0
Try:
Note the J9-1 works because Excel recognizes 9-1 as a date i.e. September 1. If you have something that does not register as a date, it'll fail.
Book4
AB
1Job CodeDescription
2 GoDaddy - July Bill
3J123GoDaddy - July Bill - John - J123 - Joker - J123
4J000063Fuel card - Part 2/5, FUEL CARD inv. 9003230422, date: 15/05/2022 - J000063 - Marine View, Fleetwood
5J129PayByPhone Parking - Premier House; 07/03/2024; 6490 - J129
6J132KaydeeSayfa - PO5598, Church Road, Crosby, 1st retention - J132
7J105Drive Card Europe - J105 (GEM Foston) - J105
8J9-1Interest on loan and HP loan agreements - Interest (J9-1 LE69 LHR)
Sheet3
Cell Formulas
RangeFormula
A2:A8A2=LET(t,TEXTAFTER(TEXTSPLIT(B2," "),"J"),XLOOKUP(TRUE,ISNUMBER(--t),"J"&t,""))
 
Upvote 0
you guys are too good! Thank you. The biggest problem now is that the data coming from different sources can J000132 or J132 by the looks of it. I guess I could create a static look up table for the projects though to refer to that.

Job CodeJob NameDescription
J000132#N/ADaniel Vivian - Week: 01-07/01/2024; Description: 4 days @£220; J000132 - Church Road
J132Church Road, CrosbyFuel card - Church Road, Crosby - J132
 
Upvote 0
Book4
AB
1Job CodeDescription
2 GoDaddy - July Bill
3J123GoDaddy - July Bill - John - J123 - Joker - J123
4J63Fuel card - Part 2/5, FUEL CARD inv. 9003230422, date: 15/05/2022 - J000063 - Marine View, Fleetwood
5J129PayByPhone Parking - Premier House; 07/03/2024; 6490 - J129
6J132KaydeeSayfa - PO5598, Church Road, Crosby, 1st retention - J132
7J105Drive Card Europe - J105 (GEM Foston) - J105
8J9-1Interest on loan and HP loan agreements - Interest (J9-1 LE69 LHR)
9J132Fuel card - Church Road, Crosby - J132
10J132Daniel Vivian - Week: 01-07/01/2024; Description: 4 days @£220; J000132 - Church Road
Sheet3
Cell Formulas
RangeFormula
A2:A10A2=LET(t,TEXTAFTER(TEXTSPLIT(B2," "),"J"),XLOOKUP(TRUE,ISNUMBER(--t),"J"&IF(ISNUMBER(SEARCH("-",t)),t,--t),""))
 
Upvote 0
Thank you so much guys. 99% there for sure. I have mostly three types of entries now that it fails on. Hundreds of each of these types.

1737042328112.png
 
Upvote 0
You should understand that Excel is not human and it only follows instructions so there needs to be a consistent rule. The rule that it has been following is that extract anything that starts "J" and follows by anything that it recognizes as a number.
The second and third case should work as it follows these rules where:
  • 9-2 is a date (serial number)
  • -1 is a number
The first case fails because it does not follow these rules. Until you can come up with a consistent rule across all entries, you can't get them all.
 
Upvote 0

Forum statistics

Threads
1,225,616
Messages
6,186,016
Members
453,334
Latest member
Prakash Jha

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