0
votes

I'm having trouble figuring out how to set multiple criteria for a SumIf statement in VBA. This is what I'm using right now with only one criterion to set the value of a variable called Count_1.

Count_1 = Application.SumIf(Range("K84:K" & LastRow), "B*", Range("G84:G" & LastRow))

I need to add another criterion. In addition to the value in column K needing to begin with "B", the value in column L also needs to be 80.

I know this can be done using SumIfs in an Excel formula, but I need it to be in VBA.

1
sumifs should helpNathan_Sav
SUMIFS exists in vba, under Application.WorkSheetFunction.Sumifs()Scott Craner
I tried using this, and it's not working. Count_1 = Application.SumIfs(Range("K84:K" & LastRow), "B*", Range("L84:L" & LastRow), "80", Range("G84:G" & LastRow))Robby
Try it without the quotes: 80 instead of "80"Scott Craner
I still get the same error.Robby

1 Answers

4
votes

Use

Application.Sumifs(SumRange, CriteriaRange1, Criteria1, CriteriaRange2, Criteria2,...)