Solved

Using substring in excel 2007 to pull out numbers

Posted on 2011-03-02
3
1,145 Views
Last Modified: 2012-05-11
I am using sumifs to add data on a spreadsheet.  The field that I would like to compare is concatanated as follows:

  01 - Red
  02 - Yellow
  03 - Blue
  04 - Green

I would like to compare just to the numeric part of the string when reading the spreadsheet.  What is the substring statement I would use to isolate the numbers.  The string is indented so the numbers are not in columns 1 and 2. It appears there are possibly 2 spaces in front of the numbers.
0
Comment
Question by:morinia
[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
  • 2
3 Comments
 
LVL 50
ID: 35023270
Hello,

you can extract the number like this

=LEFT(A1,FIND("-",A1&"-")-1)+0

cheers, teylyn
0
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst (Microsoft MVP / EE MVE) earned 250 total points
ID: 35023323
Please find attached a sample with a Sumproduct that counts the occurrences of the numbers in the range.

One option is if the comparison with true numbers (in D2)

=SUMPRODUCT(--(LEFT($A$2:$A$11,FIND("-",$A$2:$A$11)-2)+0=D2))


Another option is the comparison with text, like 01, 02, 03 (in G2)

=SUMPRODUCT(--(TRIM(LEFT($A$2:$A$11,FIND("-",$A$2:$A$11)-1))=G2))

cheers, teylyn
Book3.xls
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 35023340
If you want to retain the leading zeros, you'll need to take a similar approach:

=Trim(Left(A1, Find("-", A1&"-") -1))
0

Featured Post

SharePoint Admin?

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

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

705 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