+ Reply to Thread
Results 1 to 10 of 10

Assigning a value to a range of numbers

  1. #1
    Registered User
    Join Date
    11-24-2016
    Location
    Victoria, Australia
    MS-Off Ver
    2016
    Posts
    14

    Assigning a value to a range of numbers

    Trying to find a formula that can help me give a value to different range of numbers.

    The numbers will range between 600 to -600 and will change constantly.

    400 to 600 =10
    250 to 399=7.5
    100 to 249 =5
    99 to -99 =0
    -100 to -249 = -5
    -200 to -399 = -7.5
    -400 to -600 = -10

    so if a1=140 b2=5
    if a1=-415 b2=-10
    if a1=50 b2 =0

    Thanks in advance

  2. #2
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Assigning a value to a range of numbers

    Hi whacknal- Try this:
    =CHOOSE(MATCH(A1,{-600,-399,-249,-99,100,250,400}),-10,-7.5,-5,0,5,7.5,10)

    BTW, not that it matters, but in your list of ranges, I think -200 should be -250.

    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Last edited by leelnich; 07-08-2017 at 01:38 AM.

  3. #3
    Registered User
    Join Date
    11-24-2016
    Location
    Victoria, Australia
    MS-Off Ver
    2016
    Posts
    14

    Re: Assigning a value to a range of numbers

    You are a superstar. Continuously astounded by the smarts of people on here. Thank you very much!!

    And yes I did mean -250.....lol

  4. #4
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Assigning a value to a range of numbers

    Happy to help, thank you for the rep!

  5. #5
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Assigning a value to a range of numbers

    Instead of hard coding the lookup values, set up a lookup table as shown in the image so that you can change them when required and try this formula...

    In B1
    Please Login or Register  to view this content.
    and copy it down.
    Lookup.JPG
    Last edited by sktneer; 07-08-2017 at 03:07 AM. Reason: Correction in lookup table as pointed out by leelnich
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  6. #6
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Assigning a value to a range of numbers

    Hi sktneer- Your negative lookup numbers are reversed. You need to switch columns E and F in rows 1-3 so the largest number is always in F.
    BTW, I considered a look-up. If the list were any longer, I too would have taken that approach.

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Assigning a value to a range of numbers

    Good catch leelnich!
    Thanks for pointing that out. Much appreciated.

  8. #8
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Assigning a value to a range of numbers

    Also, SUMIFS isn't very efficient here. In this case, it must do 8-14 comparisons AND set up a sum! VLOOKUP (using approximate match) does a binary search, requiring a maximum of 4 comparisons.
    In B1:
    =VLOOKUP(A1,$E$1:$F$7,2)

    Row\Col
    A
    B
    C
    D
    E
    F
    1
    331
    7.5
    -600
    -10
    2
    -418
    -10
    -399
    -7.5
    3
    113
    5
    -249
    -5
    4
    -186
    -5
    -99
    0
    5
    -58
    0
    100
    5
    6
    -151
    -5
    250
    7.5
    7
    -193
    -5
    400
    10


    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Last edited by leelnich; 07-08-2017 at 03:29 AM.

  9. #9
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Assigning a value to a range of numbers

    That's all about personal preference. If you have a lookup table with lower and upper boundaries, it looks more readable. Isn't it?

  10. #10
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Assigning a value to a range of numbers

    Yes, it is, though the more numbers you enter, the bigger the chance of making a mistake, as demonstrated in post #1 (-200 should have been -250). Sorry if I got a little strident, the avoidance of slow calculation, which can lead to loss of user focus, has been a HUGE issue with several large projects lately. Take care-Lee

+ 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] need some help on assigning numbers
    By nth34 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-08-2015, 01:56 AM
  2. Assigning a word to a range of numbers
    By jodir in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-07-2013, 04:55 PM
  3. Help with assigning individual ref numbers
    By Richardmckevitt in forum Excel General
    Replies: 2
    Last Post: 09-20-2011, 08:59 AM
  4. Excel 2007 : Assigning numbers to rows...
    By mflynn in forum Excel General
    Replies: 2
    Last Post: 04-21-2010, 11:58 AM
  5. Assigning rows to row numbers
    By sektor666 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 01-14-2010, 09:51 AM
  6. Assigning numbers to names
    By Levi in forum Excel General
    Replies: 1
    Last Post: 05-04-2006, 05:40 PM
  7. Assigning numbers to a like items
    By woemlavy in forum Excel General
    Replies: 4
    Last Post: 11-17-2005, 09:55 PM

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