Solved

Excel formula

Posted on 2016-11-18
6
27 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
  • 3
  • 2
6 Comments
 
LVL 32

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 46

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 32

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 46

Expert Comment

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

896 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now