Extracting Data Between two Different Characters in Excel

1

I have data in the following format in Excel:

ABC - DEF - XYZ; GHI, JKL, MNO, PQR, STU, VWX, YYY, ZZZ

Is is it possible to extract the data between the second hyphen "-" and the semicolon ";" - in this case XYZ?

Thanks!

Alex Grey

Posted 2017-03-17T11:06:30.620

Reputation: 13

Answers

0

I use free regex add-in (http://www.codedawn.com/excel-add-ins.php), with that you can easily create a formula to select the desired text:

=RegExReplace(A1,"(.*-){2}(.*);.*","$2")

enter image description here

Máté Juhász

Posted 2017-03-17T11:06:30.620

Reputation: 16 807

1

If you don't want to use Add-in you can use the following:

=TRIM(MID(A1,SEARCH("-",A1,SEARCH("-",A1,1)+1)+1,SEARCH(";",A1,1)-SEARCH("-",A1,SEARCH("-",A1,1)+1)-1))

A1 is where you have your string
Search will find the second "-" (you can copy paste it in your formula if you are not sure") and first ";"
Trim to remove unwanted spaces

yass

Posted 2017-03-17T11:06:30.620

Reputation: 2 409

1

How about:

=TRIM(MID(A1,(FIND("-",A1,(FIND("-",A1)+1))+1),FIND(";",A1,(FIND("-",A1,(FIND("-",A1)+1))+1))-(FIND("-",A1,(FIND("-",A1)+1))+1)))

For example:

enter image description here

Gary's Student

Posted 2017-03-17T11:06:30.620

Reputation: 15 540