+ Reply to Thread
Results 1 to 10 of 10

If Statement using values within range

  1. #1
    Registered User
    Join Date
    05-23-2010
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2003
    Posts
    5

    If Statement using values within range

    Hello,

    The question is this.

    Cell in Sheet 1 A2 has a number (1-10). A range exisits in Sheet 2 where numbers 1-5 are catorigzied as blue, and where 6-10 are catogorized as red. In Sheet 1 B2 I need a formula that states if A2 is equal to a value within a range (lets say blue) then Cell B2 will reflect the text "Blue". I will then use nested If statments if untrue to check if cell B2 is equal to anothe value within another range and so on.

    the only thing I can come up with is this: =IF(A1=Blue,"Y",IF(A1=Red,"Y"," ")) but it returns the error #VALUE.

    any suggestions

  2. #2
    Registered User
    Join Date
    07-27-2010
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: If Statement using values within range

    Hi,

    You need to use quotation marks when referencing text:

    =IF(A1="Blue","Y",IF(A1="Red","Y"," "))

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: If Statement using values within range

    =IF(A1<6,"blue","red")
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Registered User
    Join Date
    05-23-2010
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: If Statement using values within range

    Thanks for the reply but that doesnt do it. That makes the formula look to see if the cell is = specifically to the text "Blue" rather than looking to see if it matches one of the values which is within the range Blue.

    To clarify in Sheet two A2:A6 has been named as range Blue and A8:A12 has been named as range Red. What I need in Sheet 1 B2 is a formula that looks at the value of Sheet 1 A2 and checks to see if it is an applicable value within range Blue and if so state Blue. If not Check to see if the value is an applicable value within range Red and so on. If all untrue then reflect blank value (" ").

    A1 Blue
    A2 1
    A3 2
    A4 3
    A5 4
    A6 5
    A7 Red
    A8 6
    A9 7
    A10 8
    A11 9
    A12 10

    Thanks tho.

  5. #5
    Registered User
    Join Date
    05-23-2010
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: If Statement using values within range

    I am using numerical values in the spirit of simplicity. The values within the Ranges I have named are truly text. So maybe I should state something similar to the follwing.


    A1 Blue
    A2 Light
    A3 Royal
    A4 Sea
    A5 Sky
    A6 Navy
    A7 Red
    A8 Fire Engine Red
    A9 Light Red
    A10 Burgundy
    A11 Magenta
    A12 Scarlet

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: If Statement using values within range

    well i dont think you can like that best you assign a value to each something like

    A1 Blue 1.0
    A2 Light 1.1
    A3 Royal 1.2
    A4 Sea 1.3
    A5 Sky 1.4
    A6 Navy 1.5
    A7 Red 2.0
    A8 Fire Engine Red 2.1
    A9 Light Red 2.2
    A10 Burgundy 2.3
    A11 Magenta 2.4
    A12 Scarlet 2.5


    ahh a rethink perhaps like attached
    Attached Files Attached Files
    Last edited by martindwilson; 11-07-2010 at 03:35 PM.

  7. #7
    Registered User
    Join Date
    05-23-2010
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: If Statement using values within range

    Thanks for your insight. Won’t be able to attach a numerical value but certainly a good thought.

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: If Statement using values within range

    see above but you couldn't have blue/light AND red/light they'd have to be different

  9. #9
    Valued Forum Contributor
    Join Date
    10-17-2010
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013, 2016, 2019, 365
    Posts
    294

    Re: If Statement using values within range

    You can use a VLOOKUP to categorise data by a range of values.

    Have a look at this link.

  10. #10
    Registered User
    Join Date
    06-01-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: If Statement using values within range

    I know I'm really late to this post, but wanted to chime in just incase someone else had this same question.

    You have you use a "IF(And" nested function to make this work.

    =IF(AND(A1>=1,A1<=5),"RED",IF(AND(A1>=6,A1<=11),"Blue"))

    So this statement is saying if A1 is greater than or equal to 1 (AND) less than or equal to 5 then return "RED" Then there's another statement which is the same, but would be concidered the "NESTED" part of your formula. the nested statement is saying if A1 is greater than or equal to 6 (AND) less than or equal to 11 then return "BLUE". I've used this statement for Date ranges. so i do know that you can nest upto 12 statements maybe more.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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