Formula to extract and concatenate

mmorris1965

New Member
Joined
Mar 14, 2016
Messages
6
Seeking a nested formula to extract specific numbers from the cells in column "A" and concatenate with data in column "B". Because some of the cells contain leading alpha characters and some do not, I am having trouble using the Mid function in my formula. I've shown the desired result in column "C".

Any assistance would be appreciated.

1609287628548.png
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Maybe
Edit: formula incorrect for row 3... deleted
 
Last edited:
Upvote 0
Not pretty, but assuming the value in A is after the 3rd /

=LEFT(MID(A2,FIND(CHAR(160),SUBSTITUTE(A2,"/",CHAR(160),3))+1,LEN(A2)),FIND("/",MID(A2,FIND(CHAR(160),SUBSTITUTE(A2,"/",CHAR(160),3))+1,LEN(A2)))-1)&"-"&B2


*similar to Marks, but looking at everything between the 3rd and 4th /.
 
Upvote 0
Another adaption...
Excel Formula:
=TRIM(MID(A2,FIND("#",SUBSTITUTE(A2,"/","#",3))+1,FIND("~",SUBSTITUTE(A2,"/","~",4))-FIND("~",SUBSTITUTE(A2,"/","~",3))-1))&"-"&B2
All very similar

Book2
ABC
2-/01/-/1-6120/RECPT10151-6120-1015
3CCH/01/-/01-6230/REC101701-6230-1017
Sheet2
Cell Formulas
RangeFormula
C2:C3C2=TRIM(MID(A2,FIND("#",SUBSTITUTE(A2,"/","#",3))+1,FIND("~",SUBSTITUTE(A2,"/","~",4))-FIND("~",SUBSTITUTE(A2,"/","~",3))-1))&"-"&B2
 
Upvote 0
Or another option if you have 365 and the Let function

Book2
ABC
2-/01/-/1-6120/RECPT10151-6120-1015
3CCH/01/-/01-6230/REC101701-6230-1017
Sheet2
Cell Formulas
RangeFormula
C2:C3C2=LET(first,FIND("~",SUBSTITUTE(A2,"/","~",3)),TRIM(MID(A2,first+1,FIND("~",SUBSTITUTE(A2,"/","~",4))-first-1))&"-"&B2)
 
Upvote 0
Give this formula a try...
Excel Formula:
=TRIM(LEFT(RIGHT(SUBSTITUTE(A2,"/",REPT(" ",100)),200),100))&"-"&B2
 
Upvote 0
Some timing results I find a little surprising...
I expected
The formula in post 3 to be faster than post 4
The Let formula in post 5 to be faster than both
Rick's formula in post 6 to be competing with / or beating the Let formula.

The results are below (timed using FastExcel on 10,000 rows of data, times in milliseconds) the last row is the Average.
Not that it makes much difference as there is only a range of 6 milliseconds between them (and I only really wanted to test the Let function).

Post 4Post 3Post 5Post 6
22.46124.45118.85326.286
22.45128.84118.37525.679
23.57325.63717.53422.854
22.52124.76818.24222.903
21.99224.95217.55923.812
22.599625.729818.112624.3068
 
Last edited:
Upvote 0
Rick's formula in post 6 to be competing with / or beating the Let formula.
I'm confused. Unless I don't understand your table, it seems to show that my formula never beats the Let formula. What am I missing? I agree the 6 ms difference means that all formulas are virtually the same speed-wise (as usually tends to be the case, mine is shorter though), but I wanted to understand your statement.
 
Upvote 0
I'm confused. Unless I don't understand your table, it seems to show that my formula never beats or even comes close to tying the Let formula. What am I missing?
The top paragraph is what I was expecting, not a summary of the results.
 
Upvote 0

Forum statistics

Threads
1,215,310
Messages
6,124,187
Members
449,147
Latest member
sweetkt327

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