+ Reply to Thread
Results 1 to 4 of 4

finding a reference code where the code refers to a range of values

  1. #1
    Registered User
    Join Date
    01-06-2016
    Location
    Douglas, Isle of Man
    MS-Off Ver
    2010
    Posts
    2

    finding a reference code where the code refers to a range of values

    I have tried searching for this but with no joy. Any help would be appreciated.

    I have a very large table of data where each record shows a value for a particular variable (CO2 emissions in this case) and that value will fall into one of 15 possible categories where each category relates to a range of values. The lowest category is for any value below 50 and the highest for any value greater than 255. The size of each category in between is not uniform with some being wider than others.

    So, i need a formula or possibly VBA code which checks the CO2 value - say 176 - and finds the corresponding category which would be K in this case. I don't think that I can use nested if functions or the formula would be huge.

    Thanks.

    Ian Ha

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: finding a reference code where the code refers to a range of values

    Using this example:

    A
    B
    1
    RangeStart
    Category
    2
    0
    Cat_01
    3
    30
    Cat_02
    4
    35
    Cat_03
    5
    44
    Cat_04
    6
    71
    Cat_05
    7
    99
    Cat_06
    8
    106
    Cat_07
    9
    110
    Cat_08
    10
    153
    Cat_09
    11
    159
    Cat_10
    12
    165
    Cat_11
    13
    232
    Cat_12
    14
    238
    Cat_13
    15
    247
    Cat_14
    16
    255
    Cat_15

    D1: a value to categorize: 176
    This formula returns the category for that value
    Please Login or Register  to view this content.
    In that example, the formula returns: Cat_11
    because 176 greater than or equal to 165 and less than 232

    Other sample values:

    D
    E
    1
    14
    Cat_01
    2
    118
    Cat_08
    3
    162
    Cat_10
    4
    176
    Cat_11
    5
    183
    Cat_11
    6
    236
    Cat_12
    7
    238
    Cat_13
    8
    279
    Cat_15

    Is that something you can work with?
    Last edited by Ron Coderre; 01-06-2016 at 10:03 AM.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    01-06-2016
    Location
    Douglas, Isle of Man
    MS-Off Ver
    2010
    Posts
    2

    Re: finding a reference code where the code refers to a range of values

    Dear Ron,

    That is perfect and deceptively simple. I was, typically, looking for a complex solution.

    Thanks a million.

    Ian

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: finding a reference code where the code refers to a range of values

    Glad you got something you can use!

    If that resolves your issue, please take a moment to mark this thread as SOLVED (from the Thread Tools menu)

+ 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. Replies: 2
    Last Post: 12-11-2014, 03:26 PM
  2. [SOLVED] the code is finding repeated values but i need to search values from E column to D
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-14-2014, 01:33 AM
  3. VBA code finding values/tags on a site and import it to EXCEL
    By a1b2c3d4e5f6g7 in forum Excel General
    Replies: 0
    Last Post: 04-16-2014, 12:50 PM
  4. How do i reference a dynamic cell range in VBA code
    By alice03 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-08-2013, 10:56 AM
  5. Excel VBA Code for finding the 10th percentile value for a certain bin Range
    By raishikoh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-14-2013, 06:49 PM
  6. Replies: 12
    Last Post: 07-08-2011, 10:48 AM
  7. finding error values with VBA code
    By levo_redkid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-10-2008, 12:39 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