Reputation: 55
I've got a small VBA code that searches column 3 of Sheet1 for the phrase "Rec", sums the corresponding values in column 4, and places the sum in another sheet. Works great and is the following:
Sub SumIf()
Worksheets("Sheet2").Activate
Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = _
Application.SumIf(Sheet1.Columns(3), "Rec", Sheet1.Columns(4))
End Sub
I now want it to incorporate another search criteria if possible--sum column 4 IF column 3 = "Rec" and column 5 ="UNK".
I've looked around a bit and haven't found much helpful/relevant info. Is it possible to have two search conditions in one SumIf? Any help would be greatly appreciated, thanks.
Upvotes: 0
Views: 1946
Reputation: 1534
You can use SUMIFS
The syntax is bit different first the sum range , then the criteria range and then the criteria..
Application.SumIfs(Sheet1.Columns(4), Sheet1.Columns(3), "Rec", Sheet1.Columns(5), "UNK")
Upvotes: 2