+ Reply to Thread
Results 1 to 12 of 12

Choose a number group from a single number input.

  1. #1
    Forum Contributor
    Join Date
    10-10-2006
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2019, Win 10
    Posts
    102

    Choose a number group from a single number input.

    I have nine Age Groups: 14-17, 18-24, etc. upto 85-94 and they occupy nine cells B1 to J1. If I input an age, say, 22 in cell A1, I would like the relevant Age Group, '18-24', displayed in A2. This would apply to any entered age from 14 to 94 which would result in the appropriate Age Group displayed.

    I probably could use loads of nested 'IFs', but is there a simpler way to achieve this?

    I've just installed Excel 2019 a few weeks ago, so I'm not upto speed with any of the latest functions - yet.

    Reagards,

    Alan
    Last edited by Zagra147; 05-03-2020 at 10:07 AM.

  2. #2
    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,681

    Re: Choose a number group from a single number input.

    You really don't need Excel's latest functions for this - an old favourite does the job.

    You need to create a lookup table that consists of the first age in each band on the left and the age band itself on the right, then use a VLOOKUP:

    Excel 2016 (Windows) 32 bit
    C
    D
    27
    4
    4-17
    28
    18
    18-24
    29
    85
    85-94
    30
    31
    32
    22
    18-24
    Sheet: Test

    Excel 2016 (Windows) 32 bit
    D
    32
    =VLOOKUP(C32,$C$27:$D$29,2,1)
    Sheet: Test
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Choose a number group from a single number input.

    Hey Alan,

    I call this problem a VLookup with the last argument as TRUE. Read about it at:
    https://www.wallstreetmojo.com/vlookup-with-true/
    The "1" in Ali's formula above means True. Note: You need to have your data sorted from small to large to use VLookup(,,,True)
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Forum Contributor
    Join Date
    10-10-2006
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2019, Win 10
    Posts
    102

    Re: Choose a number group from a single number input.

    Thankyou for your replies. But, with respect a simple VLOOKUP will not work here. (I have used VLOOKUP many times in other data sheets).
    The formula must take the value in cell A! (which can be any number from 14 to 94) and examine the number range in each Age Group to find a match. If A1 = 35, "35-44" is displayed, if A1 = 38, "35-44" is displayed, if A1 = 93, "85-94" is displayed, and so-on for any number from 14 to 94.
    The 'Enter Age' (cell A1) is not part of the Age Group array (which is horizontal) and can be remotely placed.
    I had thought that 'CHOOSE' and 'MATCH' might be involved, but I'm not familiar with their usage. Maybe 2019 has something extra?

    Regards,

    Alan

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Choose a number group from a single number input.

    As I understood the question, I would have expected VLOOKUP(...,TRUE) would have worked for you, and your latest post does not explain to me why it does not work. Do you have a specific example where it doesn't work so we can see why it doesn't work? That would help us come up with an alternative formula.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    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,681

    Re: Choose a number group from a single number input.

    Alan - there is no reason why my solution won't work based on your latest description. To be sure, please attach a workbook with the layout that you are dealing with and I will advise you how to implement it. Instructions at the top of this page.

  7. #7
    Forum Contributor
    Join Date
    10-10-2006
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2019, Win 10
    Posts
    102

    Re: Choose a number group from a single number input.

    Book1.xlsx
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Choose a number group from a single number input.

    The only difference between your latest example and AliGW's example is that your data are arranged horizontally (where her data are arrange vertically). Same principle applies, only use the HLOOKUP() function instead of the VLOOKUP() function:

    1) Enter 14 in D5, 18 in E5, 25 in F5, and so on.
    2) Enter your lookup value in N5
    3) Enter your HLOOKUP(...,TRUE) function in N8 =HLOOKUP(N5,D5:L10,2,TRUE)

    Does that work?

  9. #9
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,907

    Re: Choose a number group from a single number input.

    Try this:

    =IF(OR(N11<14,N11>94),"#N/A",HLOOKUP(N11&"-9*",$D$6:$L$6,1,1))

  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,681

    Re: Choose a number group from a single number input.

    Try this:

    =LOOKUP(N5,VALUE(LEFT($D$6:$L$6,2)),$D$6:$L$6)

    Then in N11 copied down:

    =INDEX($D7:$L7,MATCH($N$8,$D$6:$L$6,0))
    Last edited by AliGW; 05-09-2020 at 02:34 AM.

  11. #11
    Forum Contributor
    Join Date
    10-10-2006
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2019, Win 10
    Posts
    102

    Re: Choose a number group from a single number input.

    Thankyou ABGW. Your downloaded example works perfectly. The 'INDEX' formula is not required, but I shall bear that in mind (I included the data & calc. cells as an illustration of the spreadsheet structure. The 'calc.' cells use other data extra to the Age Group cells (not just a copy). That is no problem).
    One note, though. The downloaded formula is displayed as an ARRAY formula - yet it works fine when copied to the spreadsheet without entering as an ARRAY?

    Many thanks,

    Alan

  12. #12
    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,681

    Re: Choose a number group from a single number input.

    Yes, that’s correct in the latest versions of Excel, and you have 2019.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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: 11
    Last Post: 11-19-2019, 11:36 PM
  2. Divide a column by a number and group results in columns of that number
    By AnthonyMarx in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-02-2016, 02:06 PM
  3. How to add group number to equally divide number of rows
    By neualex in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-09-2015, 03:34 PM
  4. Replies: 6
    Last Post: 11-26-2013, 05:21 PM
  5. [SOLVED] Pulling multiple index results from a single input number
    By cwatsonSONA in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-11-2013, 11:00 AM
  6. [SOLVED] Create serial numbers based on a single input number.
    By jmp601 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-08-2013, 11:33 AM
  7. How Get the Invoice Number and Range the number, Group by Sales Name
    By antoni in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2009, 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