In Excel, it’s not possible to use the AVERAGEIF() function to calculate an average value using multiple ranges.
However, you can use the following formula as a workaround:
=(SUM(SUMIF(A2:A11,G2,B2:B11),SUMIF(D2:D11,G2,E2:E11))/SUM(COUNTIF(A2:A11,G2),COUNTIF(D2:D11,G2)))
This particular formula finds the average of the values in the ranges B2:B11 and E2:E11 where the corresponding values in the ranges A2:A11 and D2:D11 are equal to the value in cell G2.
The following example shows how to use this formula in practice.
Example: Using AVERAGEIF with Multiple Ranges in Excel
Suppose we have the following data in Excel that shows the sales of various fruits on different days:

Now suppose we would like to calculate the average daily sales of Mangos.
We can use the following formula to do so:
=(SUM(SUMIF(A2:A11,G2,B2:B11),SUMIF(D2:D11,G2,E2:E11))/SUM(COUNTIF(A2:A11,G2),COUNTIF(D2:D11,G2)))
We’ll type this formula into cell H2 and then press Enter:

We can see that the average daily sales of Mangos is 6.5.
We can verify this is correct by manually taking the average of all sales values where the corresponding product is Mangos:
Average Mango Sales: (8 + 6 + 5 + 4 + 8 + 8) / 6 = 6.5.
This matches the value that we calculated using our formula.
Note: In this example, we calculated an average using two cell ranges, but we can use similar syntax to include any number of cell ranges that we’d like.
Additional Resources
The following tutorials explain how to perform other common tasks in Excel:
Excel: How to Average If Not Blank
Excel: How to Calculate Average Excluding Outliers
Excel: How to Calculate the Average by Group
Thanks very much. It was really helpful and solve my plight.
You are very welcome John! We greatly appreciate your feedback!
How to calculate average for non-continuous cells with 0 value in some cells
If you’re working in Excel and want to calculate the average of a few non-continuous cells — like A1, C1, E1, and G1 — but some of them might contain zeros, and you want to ignore those zeros in the average, there are a couple of good ways to do it.
Option 1: Use AVERAGEIF with a manual list of cells
You can write a formula like this:
“`
=AVERAGEIF((A1,C1,E1,G1), “<>0″)
“`
This tells Excel to only include cells that are not equal to zero when calculating the average. If you’re using an older version of Excel, you may need to press Ctrl + Shift + Enter to confirm it as an array formula. In newer versions like Excel 365, you can just press Enter.
Option 2: Use a helper column or range
If you prefer not to type each cell directly in the formula, you can create a small range elsewhere in the sheet, like Z1 to Z4, and place the values from A1, C1, E1, and G1 there. For example:
* Z1 = A1
* Z2 = C1
* Z3 = E1
* Z4 = G1
Then, you can use this formula:
“`
=AVERAGEIF(Z1:Z4, “<>0″)
“`
This does the same thing but can be easier to manage, especially if your original cells are spread across the sheet.
Option 3: Use the AVERAGE and IF functions together
Another method is to use a formula like this:
“`
=AVERAGE(IF((A1,C1,E1,G1)<>0, (A1,C1,E1,G1)))
“`
This also skips the zeros and averages the rest. Just like the first option, this might need to be entered as an array formula using Ctrl + Shift + Enter in older Excel versions.