Solved

Using substring in excel 2007 to pull out numbers

Posted on 2011-03-02
3
1,143 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

734 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