Searching if a specific character exists afer nth occurrence of a value

johnmerlino

Board Regular
Joined
Sep 21, 2010
Messages
94
Hey all,

I have the two formulas I want to apply if the condition is true or false. Problem is I need to determine whether there's a comma after the second ampersand in a cell.

For example, if the field looks like this:
Code:
HernaraMartin,Harry & Marie Anne & Ann Sally
then I want to execute this formula:
Code:
=CONCATENATE(LEFT(A30,FIND(",",A30)-1),",",TRIM(MID(A30,FIND("&",A30,FIND("&",A30)+1)+1,LEN(A30))))

which produces this:
Code:
HernaraMartin,Ann Sally

Now if the cell looks like this:
Code:
HernaraMartin,Harry & Marie Anne & Jenners,Sally
Since there's a comma after second ampersand, I want to execute this:
Code:
=TRIM(RIGHT(A32,LEN(A32)-FIND("*",SUBSTITUTE(A32,"&","*",LEN(A32)-LEN(SUBSTITUTE(A32,"&",""))))))
which outputs this:
Code:
Jenners,Sally
Problem is how to determine whether a comma exists after that second ampersand.

Thanks for response.
 
Another option:

Code:
=IF(LEN(A1)-LEN(SUBSTITUTE(A1,",",""))<2,LEFT(A1,SEARCH
(",",A1)),"")&TRIM(RIGHT(SUBSTITUTE(A1,"&",REPT(" ",200),2),200))
 
Upvote 0

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