+ Reply to Thread
Results 1 to 9 of 9

Formula to auto generate age group based on age

  1. #1
    Registered User
    Join Date
    10-29-2020
    Location
    Ireland
    MS-Off Ver
    2016
    Posts
    16

    Formula to auto generate age group based on age

    Not great at Excel as I am only learning but I have a list of patients, their DOB and their age which is a formula.

    I want to create a formula that will select a pre-determined age group based on the age.
    The age groups are as follows 0 - 4, 5 - 17, 18 - 64, 65+
    Excel .jpg

    Be grateful for any help.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,693

    Re: Formula to auto generate age group based on age

    The best way to do this is to create a table of the age groups and use VLOOKUP to look up the group. You did not attach your actual file so I am attaching one showing the technique.

    (See yellow banner at top of page. An actual file is almost always better than a picture.)
    Attached Files Attached Files

  3. #3
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,008

    Re: Formula to auto generate age group based on age

    .
    One formula that can be pasted in H2 and copied down Col H :

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    10-29-2020
    Location
    Ireland
    MS-Off Ver
    2016
    Posts
    16

    Re: Formula to auto generate age group based on age

    Awesome thanks - couldn't get it to upload. I'll just have to hide it way over where nobody can find the table and delete it.

    Is it possible to use the VLOOKUP with dates.

    Say for example we had a patient referral come in and we want to calculate wait time (0-12wks, 12-24wks, 24-39wks, 39-52wks, 52+wks) based on either the referral date or contact date (which ever is the latest date).

    You can see on the excel sheet the referral date and then a good few cells over Date of contact/appointment and the wait time.
    Attached Files Attached Files

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,693

    Re: Formula to auto generate age group based on age

    Quote Originally Posted by Karenmc View Post
    we want to calculate wait time[...]based on either the referral date or contact date (which ever is the latest date).
    What is the start date and what is the end date? It looks like you use the same cell for both contact date and appointment date.

    How do you want to account for partial weeks?

    The idea is that you will do the same kind of thing. It's more complicated because you have to determine the start and end dates, and then calculate a number of weeks.

    As an example, it might look something like this:

    =VLOOKUP(INT(MAX(ReferralDate, ContactDate)-StartDate)/7),'Wait Time Table'!$A$1:$B$5,2,TRUE)

    This uses the number of whole weeks (ignores partial week).

  6. #6
    Registered User
    Join Date
    10-29-2020
    Location
    Ireland
    MS-Off Ver
    2016
    Posts
    16

    Re: Formula to auto generate age group based on age

    The start date would be the date the referral comes in.

    The end date would be when we have made contact/appointment for them as we either do a virtual or give them an appointment.

    Whole weeks are fine. Its just to give an approx. wait time in order to see where we may need to put on more clinics

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,693

    Re: Formula to auto generate age group based on age

    Quote Originally Posted by Karenmc View Post
    The start date would be the date the referral comes in.

    The end date would be when we have made contact/appointment for them as we either do a virtual or give them an appointment.
    I'll use that definition though it doesn't match the earlier one.
    based on either the referral date or contact date (which ever is the latest date).
    If the end date is contact or appointment, it doesn't matter which one since the same cell is used for both.

    I put the results in AA with some examples.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    10-29-2020
    Location
    Ireland
    MS-Off Ver
    2016
    Posts
    16

    Re: Formula to auto generate age group based on age

    Thanks a mill - my only issue is that it won't count up the weeks if there is no date in the appointment/contact cell.

    So ideally for that I would want to use just the referral date for those so it shows the weeks.

  9. #9
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,531

    Re: Formula to auto generate age group based on age

    Perhaps the following modification of 6StringJazzer's formula will yield what you want:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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. Generate random group of words in a cell from a large group word list in column
    By faizzsheikh in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 07-26-2018, 10:16 AM
  2. Auto-Generate Value Based on Date
    By eeframe27 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-19-2018, 06:26 PM
  3. [SOLVED] Macro to generate groups randomly of 20 numbers, being 10 of group A and 10 of group B,
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-14-2017, 08:02 AM
  4. [SOLVED] Auto Generate an ID# based on date
    By jme1013 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-13-2016, 07:21 PM
  5. [SOLVED] How to generate automatic Family Unique Group ID - Tried with few formula
    By bala04msw in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-30-2016, 06:48 AM
  6. auto generate based on percentage?
    By tondrey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-12-2010, 03:38 PM
  7. formula to generate month-to-date based on auto date
    By infinitysales in forum Excel General
    Replies: 1
    Last Post: 06-27-2008, 01:09 AM

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