WorksheetFunction.AverageIfs (Excel)
Returns the average (arithmetic mean) of all cells that meet multiple criteria.
If a cell in average_range is an empty cell, AverageIfs ignores it. If a cell in a criteria range is empty, AverageIfs treats it as a 0 value. Cells in a range that contain True evaluate as 1; cells in a range that contain False evaluate as 0 (zero). Each cell in average_range is used in the average calculation only if all of the corresponding criteria specified are true for that cell. If cells in average_range are empty or contain text values that cannot be translated into numbers, AverageIfs generates an error. If there are no cells that meet all the criteria, AverageIfs 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. Each criteria_range does not have to be the same size and shape as average_range. The actual cells that are averaged are determined by using the top, left cell in that criteria_range as the beginning cell, and then including cells that correspond in size and shape to range. For example:
AverageIfs (Arg1, Arg2, ..., Arg29)
Dim dblAverageIfs As Double
dblAverageIfs = WorksheetFunction.AverageIfs(Arg1:=, Arg2:=, Arg3:=)