+ Reply to Thread
Results 1 to 12 of 12

How to capture number of kids whose under 20 year old?

  1. #1
    Forum Contributor
    Join Date
    05-09-2010
    Location
    Malaysia
    MS-Off Ver
    Excel 2010
    Posts
    212

    How to capture number of kids whose under 20 year old?

    Hi, please help
    And look into file attachment
    Attached Files Attached Files

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: How to capture number of kids whose under 20 year old?

    Try this

    Type Leo in D2
    Type PL in D3

    Paste into E2
    =COUNTIFS(A:A,D2,B:B,">"&DATEVALUE(DAY(NOW())&"/"&MONTH(NOW())&"/" &YEAR(NOW())-20))

    Copy E2 to E3

    Note that the dates need to be recognized as dates. Suggest using a / instead of a .

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,051

    Re: How to capture number of kids whose under 20 year old?

    mrice, OP's profile (and .xls file upload) indicates 2003. If thats the case, countifS() wont work for them

    edit: also, the dates are not dates, but text that looks like dates

    edit2:
    In C2, copied down, use this to convert to dates...
    =SUBSTITUTE(B2,".","/")*1
    then for leo use this...
    =SUMPRODUCT(($A$2:$A$9="Leo")*($C$2:$C$9>TODAY()-DATE(20,0,0)))
    and for PL use this...
    =SUMPRODUCT(($A$2:$A$9="PL")*($C$2:$C$9>TODAY()-DATE(20,0,0)))
    Last edited by FDibbins; 01-13-2013 at 11:24 AM.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: How to capture number of kids whose under 20 year old?

    hi Shermaine2010, an alternative considering that you are using Excel 2003 would be:
    =SUMPRODUCT((A2:A9="Leo")*(DATEDIF(DATE(RIGHT(B2:B9,4),MID(B2:B9,4,2),LEFT(B2:B9,2)),TODAY(),"y")<20))
    that's for leo

    and for PL, just change the one in red:
    =SUMPRODUCT((A2:A9="PL")*(DATEDIF(DATE(RIGHT(B2:B9,4),MID(B2:B9,4,2),LEFT(B2:B9,2)),TODAY(),"y")<20))

    you can also refer to a cell reference like what mrice has suggested. do note that Leo actually has 4 children under 20

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  5. #5
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: How to capture number of kids whose under 20 year old?

    Hi

    Another version. In cell C2= Leo & cell C3 = PL. Then in D2 and copy to D3.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Regards Kevin


    Merged Cells (They are the work of the devil!!!)

  6. #6
    Forum Contributor
    Join Date
    05-09-2010
    Location
    Malaysia
    MS-Off Ver
    Excel 2010
    Posts
    212

    Re: How to capture number of kids whose under 20 year old?

    Quote Originally Posted by benishiryo View Post
    hi Shermaine2010, an alternative considering that you are using Excel 2003 would be:
    =SUMPRODUCT((A2:A9="Leo")*(DATEDIF(DATE(RIGHT(B2:B9,4),MID(B2:B9,4,2),LEFT(B2:B9,2)),TODAY(),"y")<20))
    that's for leo

    and for PL, just change the one in red:
    =SUMPRODUCT((A2:A9="PL")*(DATEDIF(DATE(RIGHT(B2:B9,4),MID(B2:B9,4,2),LEFT(B2:B9,2)),TODAY(),"y")<20))

    you can also refer to a cell reference like what mrice has suggested. do note that Leo actually has 4 children under 20

    benishiryo : I get your mean.Another problem is i have unknow number for the list (A2:A9). Therefore, I only can assume the list up to 5000 : A1:A500. Result appears as error. Help!

  7. #7
    Forum Contributor
    Join Date
    05-09-2010
    Location
    Malaysia
    MS-Off Ver
    Excel 2010
    Posts
    212

    Re: How to capture number of kids whose under 20 year old?

    Yes, is text format.
    I would like to use Year only to count the year old. any suggestion?

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,051

    Re: How to capture number of kids whose under 20 year old?

    If you only want to compare years, in C2, copied down...
    =VALUE(RIGHT(B2,4))

    then for Leo use...
    =SUMPRODUCT(($A$2:$A$5000="Leo")*($C$2:$C$5000>VALUE(TEXT(TODAY()-DATE(20,0,0),"YYYY"))))
    and for PL use...
    =SUMPRODUCT(($A$2:$A$5000="PL")*($C$2:$C$5000>VALUE(TEXT(TODAY()-DATE(20,0,0),"YYYY"))))

    if you have more than 5000 rows, adjust the 5000 in both cases (see bolded)

  9. #9
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: How to capture number of kids whose under 20 year old?

    in the context of the sample workbook that you uploaded in post #1, following single formula will beget 4 for Leo and 2 for PL:

    Please Login or Register  to view this content.
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  10. #10
    Forum Contributor
    Join Date
    05-09-2010
    Location
    Malaysia
    MS-Off Ver
    Excel 2010
    Posts
    212

    Re: How to capture number of kids whose under 20 year old?

    '- ----------
    Last edited by Shermaine2010; 01-14-2013 at 08:53 AM.

  11. #11
    Forum Contributor
    Join Date
    05-09-2010
    Location
    Malaysia
    MS-Off Ver
    Excel 2010
    Posts
    212

    Re: How to capture number of kids whose under 20 year old?

    Quote Originally Posted by FDibbins View Post
    If you only want to compare years, in C2, copied down...
    =VALUE(RIGHT(B2,4))

    then for Leo use...
    =SUMPRODUCT(($A$2:$A$5000="Leo")*($C$2:$C$5000>VALUE(TEXT(TODAY()-DATE(20,0,0),"YYYY"))))
    and for PL use...
    =SUMPRODUCT(($A$2:$A$5000="PL")*($C$2:$C$5000>VALUE(TEXT(TODAY()-DATE(20,0,0),"YYYY"))))

    if you have more than 5000 rows, adjust the 5000 in both cases (see bolded)

    Managed found the reason. I have have 2000 rows but 1000-2000 is blank data. Therefore formula below show error.
    SUMPRODUCT(( 'Adhoc-famil'!$A$2:$A$16=B19)*((Calender!$G$1-RIGHT('Adhoc-famil'!$F$2:$F$16,4)<21)))

    What formula i can apply for?

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,051

    Re: How to capture number of kids whose under 20 year old?

    where did the (Calender!$G$1-RIGHT('Adhoc-famil'!$F$2:$F$16,4)<21 come from??

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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