AVERAGEIF for visible rows only

Excel_BWL

New Member
Joined
Jun 8, 2017
Messages
9
https://i.gyazo.com/2a47fd1b810edc436adb16cac4f2d256.png

I want to set up a function which can average, for example, all the durations corresponding to zone "B", but ignoring any hidden rows which include times for zone "B".

AVERAGEIF doesn't work because it includes hidden rows, and SUBTOTAL doesn't have an option for AVERAGEIF.

Would appreciate some advice?

Cheers
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Not zone B, say zone D1 for example (just realised in this screenshot there is no B). Principle should still be the same though

Thanks
 
Upvote 0
I suggest a helper column to put the Subtotal function in.

Say column C or whatever, in C2 and filled down put
=SUBTOTAL(102,B2)
Where Column B contains the numbers being averaged, and column A is your zones.

Then add a criteria to averageifs to test column C for 1.

AVERAGEIFS(B:B,A:A,"Zone B",C:C,1)

Averages column B, where Column A = "Zone B" and Column C = 1
Column C = 1 if there is a number in it, AND it is a visible row, otherwise column C = 0
 
Last edited:
Upvote 0
Maybe...

=SUMPRODUCT(SUBTOTAL(103,OFFSET(A2:A25,ROW(A2:A25)-ROW(A2),0,1)),B2:B25,--(A2:A25="B"))/SUMPRODUCT(SUBTOTAL(103,OFFSET(A2:A25,ROW(A2:A25)-ROW(A2),0,1)),--(A2:A25="B"))

M.
 
Upvote 0

Forum statistics

Threads
1,226,179
Messages
6,189,472
Members
453,549
Latest member
MBenedikt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top