WorksheetFunction.AverageIf (Excel)
Returns the average (arithmetic mean) of all the cells in a range that meet a given criteria.
Cells in a range that contain True or False are ignored. If a cell in a range or average_range is an empty cell, AverageIf ignores it. If a cell in the criteria is empty, AverageIf treats it as a 0 value. If no cells in the range meet the criteria, AverageIf generates an error value. You can use the wildcard characters, question mark (?) and asterisk (*), in criteria. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character. Average_range does not have to be the same size and shape as range. The actual cells that are averaged are determined by using the top, left cell in average_range as the beginning cell, and then including cells that correspond in size and shape to range. For example:
AverageIf (Arg1, Arg2, Arg3)
Dim dblAverageIf As Double
dblAverageIf = WorksheetFunction.AverageIf(Arg1:=, Arg2:=)
Arguments
Arg1, Arg2, Arg3Arg1 (Range) - One or more cells to average.
Arg2 - The criteria in the form of a number, expression, cell reference, or text that defines which cells are averaged. For example, criteria can be expressed as 32, "32", ">32", "apples", or B4
Arg3 - The actual set of cells to average. If omitted, range is used