WorksheetFunction.SumIf (Excel)

Adds the cells specified by a given criteria.

Sum_range does not have to be the same size and shape as range. The actual cells that are added are determined by using the top, left cell in sum_range as the beginning cell, and then including cells that correspond in size and shape to range. For example:

SumIf (Arg1, Arg2, Arg3)


Dim dblSumIf As Double
dblSumIf = WorksheetFunction.SumIf(Arg1:=, Arg2:=)

Arguments

Arg1, Arg2, Arg3

Arg1 (Range) - Range - the range of cells that you want evaluated by criteria.

Arg2 - Criteria - the criteria in the form of a number, expression, or text that defines which cells will be added. For example, criteria can be expressed as 32, "32", ">32", or "apples"

Arg3 - Sum_range - the actual cells to add if their corresponding cells in range match criteria. If sum_range is omitted, the cells in range are both evaluated by criteria and added if they match criteria