+ Reply to Thread
Results 1 to 8 of 8

Group values and get max date from the grouped value

  1. #1
    Registered User
    Join Date
    02-18-2013
    Location
    Cebu, Phils
    MS-Off Ver
    Excel 2003
    Posts
    10

    Group values and get max date from the grouped value

    Hello,

    I need help on my report, I have the following data;
    Name Date
    A,Trial 12/17/2012 9:00
    A,Trial 12/16/2012 7:00
    A,Trial 12/15/2012 7:00
    B,Trial 12/16/2012 10:00
    B,Trial 12/16/2012 8:00
    C,Trial 12/16/2012 7:00
    C,Trial 12/16/2012 9:00
    C,Trial 12/19/2012 7:00

    I need some macro that will get all the maximum date grouped by name. So the result should be;

    A,Trial 12/17/2012 9:00
    B,Trial 12/16/2012 10:00
    C,Trial 12/19/2012 7:00

    Thank you all in advance.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Group values and get max date from the grouped value

    So should the other rows be deleted which are not maximum?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    02-18-2013
    Location
    Cebu, Phils
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Group values and get max date from the grouped value

    Quote Originally Posted by arlu1201 View Post
    So should the other rows be deleted which are not maximum?
    Hi arlu, thanks for seeing my thread, if possible I want it in another sheet. My brain's almost going to explode, hehehe.

  4. #4
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,740

    Re: Group values and get max date from the grouped value

    Is the data in 2 columns ?
    you could use this to fond the unique trials
    =INDEX($A$2:$A$20,MATCH(0,INDEX(COUNTIF($E$1:E1,$A$2:$A$20),0,0),0))

    and then use this to get the max
    =MAX(IF(A2:A100=E2,B2:B100)) as an array formula - so you need to use - control + shift + enter

    I will add onto a separate sheet and attach here -

    put into sheet2 A2
    =INDEX(sheet1!$A$2:$A$20,MATCH(0,INDEX(COUNTIF($A$1:A1,sheet1!$A$2:$A$20),0,0),0))
    and copy down
    then in B2 sheet2
    =MAX(IF(sheet1!A2:A20=a2,sheet1!B2:B20)) so you need to use - control + shift + enter and { } brackets should appear around the formula
    copy down
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-18-2013
    Location
    Cebu, Phils
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Group values and get max date from the grouped value

    Quote Originally Posted by etaf View Post
    Is the data in 2 columns ?
    you could use this to fond the unique trials
    =INDEX($A$2:$A$20,MATCH(0,INDEX(COUNTIF($E$1:E1,$A$2:$A$20),0,0),0))

    and then use this to get the max
    =MAX(IF(A2:A100=E2,B2:B100)) as an array formula - so you need to use - control + shift + enter

    I will add onto a separate sheet and attach here -

    put into sheet2 A2
    =INDEX(sheet1!$A$2:$A$20,MATCH(0,INDEX(COUNTIF($A$1:A1,sheet1!$A$2:$A$20),0,0),0))
    and copy down
    then in B2 sheet2
    =MAX(IF(sheet1!A2:A20=a2,sheet1!B2:B20)) so you need to use - control + shift + enter and { } brackets should appear around the formula
    copy down
    hi etaf, yes it is in two columns... it's really great! i appreciate the help, I'll try to translate your formula into macro code.

    Thanks a lot!!! Cheers!

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Group values and get max date from the grouped value

    This should do it

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  7. #7
    Registered User
    Join Date
    02-18-2013
    Location
    Cebu, Phils
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Group values and get max date from the grouped value

    Quote Originally Posted by mike7952 View Post
    This should do it

    Please Login or Register  to view this content.
    Hi Mike! Cool! Thank you very much for the code, I'll check on this once I'm no longer busy. Thank you all, this site is amazing.

  8. #8
    Registered User
    Join Date
    02-18-2013
    Location
    Cebu, Phils
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Group values and get max date from the grouped value

    Quote Originally Posted by popoyjin View Post
    Hi Mike! Cool! Thank you very much for the code, I'll check on this once I'm no longer busy. Thank you all, this site is amazing.
    Wow! Macro is working, really, really great! Thank you all!!! Problem solved, you all saved my day!

+ 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