+ Reply to Thread
Results 1 to 12 of 12

Finding a number in multiple cells with each of its own range

  1. #1
    Registered User
    Join Date
    11-03-2009
    Location
    Gary, Indiana
    MS-Off Ver
    Excel 2003
    Posts
    9

    Finding a number in multiple cells with each of its own range

    Hello All,

    So this is something that I'm not sure is possible in Excel. I would like to use an "if,then" statement to see if a number is in multiple cells. I know this is usually very simple except there's a catch here. In each cell there's a number range using a "-". So in a single cell a range would be 301-305. I am open to having the range done a different way like 301,302...etc. I just decided this would be an easy way to look at it and was hoping to find a way to solve this problem with leaving in the dash. Whatever is practical is fine with me.

    Using Example A in the attached file I want to use this statement, =IF(308 is in any of the ranges in A3:A6, TRUE, FALSE).

    So, for me, the alternative I want to avoid is Example B where I would have to list every single number and then check the whole range. I would like to avoid this because these examples, as you can imagine, are on a much smaller scale then what I will actually be dealing with.

    Hopefully my question was clear and thank you for any help in advance.

    MMM
    Attached Files Attached Files

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Finding a number in multiple cells with each of its own range

    So are you looking to see if the numbers listed in Example C are within the ranges listed in Example A?

    If so:

    =SUMPRODUCT(--(LEFT($A$3:$A$6,FIND("-",$A$3:$A$6)-1)+0<=E3),--(MID($A$3:$A$6,FIND("-",$A$3:$A$6)+1,10)+0>=E3))>0

    copied down.

    Else, make a list of all the numbers you want to check and use the above formula.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    11-03-2009
    Location
    Gary, Indiana
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Finding a number in multiple cells with each of its own range

    NBVC,

    Thank you so much! That's exactly what I'm looking for.

    However, I was wondering if you might be able to explain one part of the function for me. I understand all the functions but I can't figure out why the +0 needs to be there. I do see that if I exclude it, then it doesn't work. I would think after you use the LEFT function it should be a (integer<=E3) without the +0, but maybe I just don't know something about the LEFT function. Any clarity would be great. Thanks.

    MMM

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Finding a number in multiple cells with each of its own range

    You are correct except that the LEFT() function returns the integer as a Text Value and so the +0 coerces it to an actual Number that Excel understands as a number.

  5. #5
    Registered User
    Join Date
    11-03-2009
    Location
    Gary, Indiana
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Finding a number in multiple cells with each of its own range

    Ah, that makes a lot of sense. Thank you again so much, NBVC!

  6. #6
    Registered User
    Join Date
    11-03-2009
    Location
    Gary, Indiana
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Finding a number in multiple cells with each of its own range

    I have another element to this problem. So instead of it checking for just one number, I would like it to check to make sure multiple numbers are in there. Like making sure it includes not just 1, but also 1, 2, 3, 4, and 5. I tried replacing the part that refers to the cell E3 with AND(1, 2, 3, 4, 5). I was hoping the equation would check for all 5, but that's not working. Is there a different solution that you might be able to think of?

    MMM

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Finding a number in multiple cells with each of its own range

    I am not exactly sure what you mean... can you give an example of expected result using your original sample attachment.

  8. #8
    Registered User
    Join Date
    11-03-2009
    Location
    Gary, Indiana
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Finding a number in multiple cells with each of its own range

    So, for this problem it doesn't involve Example B or Example C. Hm, I would like to have the same kind of if then statement. Looking at Example A, I would like to see if the numbers 301, 302, and 303 are in that range, not just one value. So if all of them are in there it would return True, and if not, then False. It's okay if in the equation you have to manually put in 301, 302, and 303 instead of a cell.


    As a side question, is there a way to see if a number is in just cell C3 of Example B? I figure, it gets more complicated since there is a comma in there, cause ideally I would like to have all the ranges in one cell separated by commas, but it does seem like if possible it would be messy.

    Thank you,
    MMM

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Finding a number in multiple cells with each of its own range

    First Question:

    A few ways to do it:

    Hard coded into the formula (this formula confirmed with ENTER)

    Please Login or Register  to view this content.
    If you list the numbers vertically in H3:H5 (this formula must be confirmed with CTRL+SHIFT+ENTER)

    Please Login or Register  to view this content.
    If you list the numbers horizontally in H3:J3 (this formula can be confirmed with just ENTER)

    Please Login or Register  to view this content.
    2nd Question: That would be way too complicated, better to keep it like Example A..
    Last edited by NBVC; 12-08-2009 at 10:59 AM.

  10. #10
    Registered User
    Join Date
    11-03-2009
    Location
    Gary, Indiana
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Finding a number in multiple cells with each of its own range

    Thank you again NBVC. I appreciate all your help.

    MMM

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Finding a number in multiple cells with each of its own range

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  12. #12
    Registered User
    Join Date
    11-03-2009
    Location
    Gary, Indiana
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Finding a number in multiple cells with each of its own range

    Either time has expired me from editing the first post or someone has removed it, but I don't have an edit button anymore for that first post. Are you able to change that?

    MMM

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1