Extract Text between Ampersands? Cannot Use VBA.

VBE313

Well-known Member
Joined
Mar 22, 2019
Messages
686
Office Version
  1. 365
Platform
  1. Windows
How can I extract text between ampersands? I want to have it up to 3 ampersands. I got the formula's to work up to only 1 ampersand. is there an easier way to get this without VBA? The data between the Ampersands should always start with "SO".

Snag_acf21be.png


F1 Formula
Code:
=IFERROR(IF(LEFT(A1,2)="SO",LEFT(A1,(FIND("&",A1)-2)),""),A1)

G1 Formula
Code:
=IFERROR(IF(LEFT(IF(RIGHT(TRIM(RIGHT(A1,(FIND("&",A1,1)-1))),1)<>"S",TRIM(RIGHT(A1,(FIND("&",A1,1)*1))),TRIM(RIGHT(A1,(FIND("&",A1,1)-1)))),1)="&",TRIM(RIGHT(A1,(FIND("&",A1,1)-2))),IF(RIGHT(TRIM(RIGHT(A1,(FIND("&",A1,1)-1))),1)<>"S",TRIM(RIGHT(A1,(FIND("&",A1,1)*1))),TRIM(RIGHT(A1,(FIND("&",A1,1)-1))))),"")
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Why not use Text to Columns under the Data ribbon, using & as the delimiter.
 
Upvote 0
Try this, copied across and down.

20 10 01.xlsm
ABCDE
1SO123 & SO456SO123SO456  
2    
3SO1 & SO2 & SO3 & SO4SO1SO2SO3SO4
Extract
Cell Formulas
RangeFormula
B1:E3B1=TRIM(MID(SUBSTITUTE("&"&$A1,"&",REPT(" ",100)),COLUMNS($B:B)*100,100))
 
Upvote 0
If the "SO" codes are always 13 characters long separated by " & " then you could do this (assumes the text is in cell A4):

Cell B4: =LEFT(A4,13)
Cell C4: =MID(A4,16,13)
Cell D4: =MID(A4,31,13)
Cell E4: =MID(A4,46,13)

This is up to four codes. If there are less a blank will be returned.

HTH

Robert
 
Upvote 0
Why not use Text to Columns under the Data ribbon, using & as the delimiter.
I am using Office Scripts to automate a daily task. I am not sure if Text to Columns is available in TypeScript as of right now.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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