+ Reply to Thread
Results 1 to 10 of 10

Returning a text result when cell value falls within a range

  1. #1
    Registered User
    Join Date
    02-17-2014
    Location
    Burnley, England
    MS-Off Ver
    Excel 2010
    Posts
    4

    Returning a text result when cell value falls within a range

    Hi new to the forum, thanks for any help.

    I need to create a formula that returns different text values that are determined by the value in another cell falling within a specific range.

    For example, if H42's value is anywhere between 0 and 6 I want I42 to display "BL1". If H42's value is anywhere between 7 and 12 I want I42 to display "1C", between 13 and 17 is "1B" and 18+ is "1A". I have tried doing this with the IF function but having no luck at all.

    Thanks for any help.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Returning a text result when cell value falls within a range

    Try:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  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: Returning a text result when cell value falls within a range

    Assuming you are only entering integers
    =IF(H42="","",LOOKUP(H42,{0,7,13,18},{"BL1","I42","1B","1A"}))
    "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
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Returning a text result when cell value falls within a range

    Copy and paste this into I42: =LOOKUP(I42,{0,7,13,18},{"BL1","1C","1B","1A"})

  5. #5
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Returning a text result when cell value falls within a range

    Try:

    =IF(H42>=18,"1A",IF(H42>=13,"1B",IF(H42>=7,"1C",IF(H42>=0,"BL1","display what you want"))))

    Or:

    =LOOKUP(H42,{0,7,13,18},{"BL1","1C","1B","1A"})
    Quang PT

  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: Returning a text result when cell value falls within a range

    with lookup you need to test for blank first else lookup assumes the cell is 0 and will always return BL1

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Returning a text result when cell value falls within a range

    Try this formula

    =INDEX({"BL1","1C","1B","1A"},MATCH(H42,{0,7,13,18}))
    Last edited by AlKey; 02-17-2014 at 05:29 PM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  8. #8
    Registered User
    Join Date
    02-17-2014
    Location
    Burnley, England
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Returning a text result when cell value falls within a range

    Amazing work, thanks to you all. It is working a treat

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

    Re: Returning a text result when cell value falls within a range

    dont want to be picky but
    aligw =LOOKUP(I42,{0,7,13,18},{"BL1","1C","1B","1A"}) is the wrong cell reference a typo?
    alkey =LOOKUP(H42,{0,7,13,18,100},{"BL1","1C","1B","1A"})
    you dont need anything after 18 if 100 or above you'll get #n/a
    and as i said before
    with lookup you need to test for blank first else lookup assumes the cell is 0 and will always return BL1

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Returning a text result when cell value falls within a range

    Quote Originally Posted by martindwilson View Post
    dont want to be picky but
    aligw =LOOKUP(I42,{0,7,13,18},{"BL1","1C","1B","1A"}) is the wrong cell reference a typo?
    Yes, should be J42, but I think the OP has used a different version, so no harm done.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Returning a date from a range if date falls between two other dates
    By sdavison in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-25-2013, 03:59 AM
  2. Replies: 1
    Last Post: 01-17-2013, 10:44 AM
  3. Replies: 10
    Last Post: 05-13-2012, 07:43 PM
  4. Excel 2007 : Returning cell in range that contains text
    By blessguy in forum Excel General
    Replies: 4
    Last Post: 04-17-2012, 09:43 AM
  5. Formula when result falls within a dollar range
    By tsummers2 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-03-2011, 11:23 AM

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