+ Reply to Thread
Results 1 to 9 of 9

user define function (max if)

  1. #1
    Registered User
    Join Date
    02-23-2013
    Location
    earth
    MS-Off Ver
    Excel 2010
    Posts
    21

    user define function (max if)

    I need a user define function that will return largest number given a condition,MAX IF

    The user defines function should look like, MAXif (array, condition)

    Example,
    Assume $A$1:$A$10 is list of numbers from 1 to 10.

    so
    MAXif($A$1:$A$10,">3")=10.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: user define function (max if)

    ck_123,

    Check out this thread: http://www.excelforum.com/tips-and-t...y-formula.html
    For your example, the formula would be:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

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

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: user define function (max if)

    This will do the sample but I'm not sure how useful it will be to you:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Registered User
    Join Date
    02-23-2013
    Location
    earth
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: user define function (max if)

    Quote Originally Posted by tigeravatar View Post
    ck_123,

    Check out this thread: http://www.excelforum.com/tips-and-t...y-formula.html
    For your example, the formula would be:
    Please Login or Register  to view this content.
    thank for the info,it do help but i planned to develop flexible user define function similar with excel function named aggregate (), neither macro nor formula
    Last edited by ck_123; 03-02-2013 at 05:06 AM.

  5. #5
    Registered User
    Join Date
    02-23-2013
    Location
    earth
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: user define function (max if)

    Quote Originally Posted by xladept View Post
    This will do the sample but I'm not sure how useful it will be to you:

    Please Login or Register  to view this content.
    actually i planned to develop case select user define function,maxif is just one of these,the code is working,but is that possible using code like "WorksheetFunction.Max" and "WorksheetFunction.index" to do the same thing,because i planned to develop minif,modeif,frequencyif and more,and i believe this will take a lot time and energy from all of you,so i just asking for maxif and learn to do the other.

    i tried to convert the formula given by tigeravatar =Max(Index(($A$1:$A$10>3)*$A$1:$A$10,)),but fail due to poor knowledge in VBA.

    Please Login or Register  to view this content.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: user define function (max if)

    I always found that writing WorksheetFunction everywhere became quite onerous - this is how I get around that:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-23-2013
    Location
    earth
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: user define function (max if)

    Quote Originally Posted by xladept View Post
    I always found that writing WorksheetFunction everywhere became quite onerous - this is how I get around that:

    Please Login or Register  to view this content.
    the code cant work,by the way, i using the code ,and it work.

    Please Login or Register  to view this content.
    thank for your time and energy.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: user define function (max if)

    That Index code won't work but the the Min and others like it do work with the abbreviation - you're welcome!

  9. #9
    Registered User
    Join Date
    10-03-2011
    Location
    Miami/Fort Lauderdale, Fl., USA
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: user define function (max if)

    Create a Module with the code below, then you will have a function called MAXIF, but must enable macros in sheet:


    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ 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