Need a excel formula

aryanaveen

Board Regular
Joined
Jan 5, 2015
Messages
104
Hi All,

Can someone please help me with a formula for below situation.
in below situation I need a formula in column B which will extract from right till first "-" from right, formula in column C should extract from right till second "-"

ABCD
1ABC Com - INC - 123 - XYZXYZ123 - XYZINC - 123 - XYZ
2
3
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi,

If the text length is same in column C & D then you can use below formulas

In Cell B1
Excel Formula:
=RIGHT(C1,3)

In Cell C1
Excel Formula:
=RIGHT(D1,9)
 
Upvote 0
Ok, Try this in B1 and let me know

Excel Formula:
=RIGHT(C1,LEN(C1)-SEARCH("-",C1))
 
Upvote 0
Ok, Try this in B1 and let me know

Excel Formula:
=RIGHT(C1,LEN(C1)-SEARCH("-",C1))
Formula should extract data from A1, hence modified the formula to =RIGHT(A1,LEN(A1)-SEARCH("-",A1)) and it results in INC - 123 - XYZ, I think this is searching from left but I need the formula which wil look from right
 
Upvote 0
Is A1 a text value or result of a formula ??

Edit

And will there always be 3 dashes (-) ??? in cell A1
 
Upvote 0
In B1
Excel Formula:
=RIGHT(A1,LEN(A1)-SEARCH("#",SUBSTITUTE(A1,"-","#",LEN(A1)-LEN(SUBSTITUTE(A1,"-","")))))

This will work no matter how many dashes in cell A1 & no matter what is the text length

Test it and let me know
 
Upvote 0
You could try this.

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

21 03 17.xlsm
ABCD
1
2ABC Com - INC - 123 - XYZXYZ123 - XYZINC - 123 - XYZ
3XYZ Testing - ABCDE - 2435 - XX2435 - XABCDE - 2435 - X
Extract sections
Cell Formulas
RangeFormula
B2:D3B2=TRIM(SUBSTITUTE(RIGHT(SUBSTITUTE($A2,"-",REPT(" ",100)),COLUMNS($B:B)*100),REPT(" ",101)," -"))
 
Upvote 0
Hi,

Try this:

Cell Formulas
RangeFormula
B1:K3B1=IF(COLUMNS($B1:B1)<=LEN($A1)-LEN(SUBSTITUTE($A1,"-","")),SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE($A1,"-",REPT(" ",100)),COLUMNS($B1:B1)*100))," "," - "),"")
 
Upvote 0
Hi again,

Shorter version of my formula above (Post #9):

Cell Formulas
RangeFormula
B1:I3B1=SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE($A1,"-","-"&REPT(" ",100)),COLUMNS($B4:B4)*100)),$A1,"")
 
Upvote 0

Forum statistics

Threads
1,215,457
Messages
6,124,941
Members
449,197
Latest member
k_bs

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