+ Reply to Thread
Results 1 to 7 of 7

Sumproduct UDF function in VBA

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Sumproduct UDF function in VBA

    Hello everyone
    I am trying to return a value based on three criteria ..
    Here's my try
    Please Login or Register  to view this content.
    When running the code I got an error "Type mismatch"
    Here's the attachment
    Thanks advanced for help
    Attached Files Attached Files
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Sumproduct UDF function in VBA

    What is the result that you are looking for?
    It looks like COUNTIFS would do what you want.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Sumproduct UDF function in VBA

    I want simply to depend on three criterias : first in column A - Second in Column B - Third in column C and finally return the value n column D
    I can use one of the following formulas tp do the task
    Please Login or Register  to view this content.
    or the array formula
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: Sumproduct UDF function in VBA

    Your formula string is 304 characters long - the limit is 255. Get rid of the (external:=True) and your code should work.

    Instead of a macro, you could use this in cell G7

    =GetData(G3, G4,G5)

    Or use

    =SUMIFS(D:D,A:A,G3,B:B,G4,C:C,G5)

    and skip the VBA altogether.
    Last edited by Bernie Deitrick; 02-17-2016 at 10:47 AM.
    Bernie Deitrick
    Excel MVP 2000-2010

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Sumproduct UDF function in VBA

    Thanks a lot Mr. Bernie for this wonderful help
    Actually the modification of the UDF function by removing External=true solved the problem

    But there is still a problem for me ::: the criteria may occur more than once .. in this case all solutions failed as the solutions sum the values and I don't need to sum .. In this case I need to return the first occurence only
    The only successful formula for that task is the array formula
    Please Login or Register  to view this content.
    Now I need to convert this formula to UDF function as this is a part of another complicated code ..

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: Sumproduct UDF function in VBA

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Sumproduct UDF function in VBA

    Thank you very very much for this wonderful and awesome solution
    Thanks a lot for offering help
    Kind Regards

+ 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. [SOLVED] Sumproduct and Max function
    By zeez36 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-11-2014, 11:18 AM
  2. [SOLVED] Help with Sumproduct function
    By atandon in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 10-24-2013, 12:04 AM
  3. [SOLVED] Sumproduct Function with Other Function References
    By T86157 in forum Outlook Formatting & Functions
    Replies: 4
    Last Post: 07-30-2012, 04:56 PM
  4. Replies: 9
    Last Post: 07-02-2012, 07:02 PM
  5. Replies: 10
    Last Post: 11-11-2010, 03:49 PM
  6. use of sumproduct function
    By R..VENKATARAMAN in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-22-2006, 11:00 PM
  7. [SOLVED] SUMIF Function Inside SUMPRODUCT Function
    By Abdul Waheed in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 09-19-2005, 12:05 PM

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