+ Reply to Thread
Results 1 to 6 of 6

Combining MAX with IF

  1. #1
    Registered User
    Join Date
    10-21-2010
    Location
    Bergen, Norway
    MS-Off Ver
    Excel 2010
    Posts
    3

    Thumbs up Combining MAX with IF

    Hi,

    In column (A) a list of City's - same city will appear many times.

    In column (B) a date relating to the city.

    Want to have a formula that gives me the newest date for one specific city.

    Newest date is of course highest number , so that leads me to MAX formula - but i need to combine it with an IF to get some "MAXIF" formula ???

    Any hint or suggestions?
    Last edited by Skato; 04-10-2013 at 04:30 PM.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,719

    Re: Combining MAX with IF

    You can use an "array formula" like this

    =MAX(IF(A2:A100="Bergen";B2:B100))

    confirmed with CTRL+SHIFT+ENTER
    Audere est facere

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Combining MAX with IF

    You can use an arrayed formula (enter with CNTRL SHFT ENTER rather than ENTER. If done properly you'll see brackets {} around your formula)

    with City in A and Dates in B (and City you want to find in D1)

    =MAX(IF(A2:A6=D1,B2:B6,""))
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,401

    Re: Combining MAX with IF

    Let's say the list is in cells A2 to A13 (a, b and c) and the dates are in B2 to B13

    Then: =MAX(IF($A2:$A13="a",$B2:$B13)) ... Array Entered with Ctrl-Shift-Enter will give you the highest value/date for "a"

    To generalise:

    =MAX(IF($A$2:$A$13=C2,$B$2:$B$13)) ... again, Array Entered with Ctrl-Shift-Enter

    HTML Code: 


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    10-21-2010
    Location
    Bergen, Norway
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Combining MAX with IF

    Hi,

    Thank you - It worked very well :-)

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,401

    Re: Combining MAX with IF

    You're welcome. Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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