Solved

Excel formula

Posted on 2016-11-18
6
34 Views
Last Modified: 2016-11-18
Hi

I want to split product codes which are different lengths but always have a - in the same place.  I want to create a field which is a short code version and have a formula to do the split rather than sorting and doing text to columns the data. It's always the information before the second -

So the data below is in column B
BSR-G19-BE-L
ZR-17-OL
JWS-27-BR-10

In column C I would like
BSR-G19
ZR-17
JWS-27

Many thanks
0
Comment
Question by:RichardAtk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 33

Accepted Solution

by:
Rob Henson earned 500 total points
ID: 41892997
Assuming value in B3, use formula in C3:

=LEFT(SUBSTITUTE(B3,"-","|",2),FIND("|",SUBSTITUTE(B3,"-","|",2),1)-1)

This replaces second occurence of "-" with "|" and then pulls everything to left of "|"

"|" is shift plus key next to z
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 41893012
Assumes data in A1

=LEFT(A1,FIND(CHAR(1),SUBSTITUTE(A1,"-",CHAR(1),2))-1)
0
 

Author Closing Comment

by:RichardAtk
ID: 41893024
Perfect thanks
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 33

Expert Comment

by:Rob Henson
ID: 41893025
Yep, looking at it don't need the SUBSTITUTE part in the first parameter of the LEFT function.

So just:

=LEFT(B3,FIND("|",SUBSTITUTE(B3,"-","|",2),1)-1)
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 41893041
...and you get my formula.
0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 41893046
Indeed, you do. Author accepted my post while I was writing the comment agreeing with yours.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question