ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Custom Function-sum based on multiple criteria (https://www.excelbanter.com/excel-programming/295347-custom-function-sum-based-multiple-criteria.html)

Rachel[_5_]

Custom Function-sum based on multiple criteria
 
I have created a custom function that sums one range of
cells based on criteria in another range:

dblIBilling = Application.WorksheetFunction.SumIf
(OwnerRange, employee, BillingsRange)

Now I need to add two additional criteria from a different
range.

In essence:
Sum "BillingsRange" if "OwnerRange" = employee's name (the
part I already have)
AND
"UnitsRange" = "Hour" or "Over".

I'm sure this can be done, and I've tried multiple options
but I'm not getting it.

Any advise would be appreciated!
Rachel

Tom Ogilvy

Custom Function-sum based on multiple criteria
 
This would require an array formula which you can not really use in VBA
directly. (sumproduct won't work in this instance either).

You could set up the formula and use Evaluate to return the value, but it
would need a string set up the same way you would enter it in a cell.

Otherwise, you need to loop through you range and check for the appropriate
conditions.

--
Regards,
Tom Ogilvy


"Rachel" wrote in message
...
I have created a custom function that sums one range of
cells based on criteria in another range:

dblIBilling = Application.WorksheetFunction.SumIf
(OwnerRange, employee, BillingsRange)

Now I need to add two additional criteria from a different
range.

In essence:
Sum "BillingsRange" if "OwnerRange" = employee's name (the
part I already have)
AND
"UnitsRange" = "Hour" or "Over".

I'm sure this can be done, and I've tried multiple options
but I'm not getting it.

Any advise would be appreciated!
Rachel





All times are GMT +1. The time now is 05:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com