Extracting Data From The Right of a Cell

B

Brian Ashcraft

Hello All,

Thanks in advance for you help!!

I am trying to extract data from a single cell in Excel.

Example Data:

MX04-08-1-EA
MX04-1000-100-EA
MX04-10-10000-50-EA

The data I want to extract is the data "to the left" of the "second
dash from the right".

Example Data, With Results:

MX04-08-1-EA MX04-08
MX04-1000-100-EA MX04-1000
MX04-10-10000-50-EA MX04-10-1000
MX-04-999-G7-1-EA MX-04-999-G7

My starting data can have two or more dashes in it, but will always
have a minimum of two.

For reasons which I will not go in to, I am unable to write vbScript
functions in this spreadsheet. I need to use the MID, LEN, FIND, etc
to accomplish this.

ANY help is much apprecaited....
 
R

Rick Rothstein

The data I want to extract is the data "to the left" of
the "second dash from the right".

Give this formula a try...

=LEFT(A1,FIND("?",SUBSTITUTE(A1,"-","?",LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))-1))-1)

Rick Rothstein (MVP - Excel)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top