Equation to retrieve the average of the last three non-zero entries in a range

SloFlyer

New Member
Joined
Feb 1, 2005
Messages
16
I would like to get an cell equation that provides the average of the last three non-zero entries in a range. Given the data
Value Desired Result
1
0
0
2
3 2
0 2
4 3
0 3
5 4
6 5
7 6
8 7
0 7
9 8
0 8

where cell A1="Value" and "A15"=9 etc. Starting with row 6, the average of the last three non-zero entries in column A is 2=(1+2+3)/3 in cell "B6" for the range "A2:A6". In cell "B14", the average is 7=(6+7+8)/3 for the range "A2:A14". I tried to come up with a range that would grow or shrink to get three non-zero cells, but couldn't work it out. HELP!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Try this array formula in B6

=AVERAGE(IF(A$2:A6<>0,IF(ROW(A$2:A6)>=LARGE(IF(A$2:A6<>0,ROW(A$2:A6)),3),A$2:A6)))

confirm with CTRL+SHIFT+ENTER and copy down
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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