Moving average skipping cells that contain certain character

triforce

New Member
Joined
Jul 1, 2015
Messages
12
wind.size
30-843-2127
4
532
10

<tbody>
</tbody>

1) I want to create a moving average (going to the right) with a defined window size (A2).
2) I don't want to return a number if the character above is a dash.
3) For the moving average I want to skip cells that contain a dash above (i.e. moving average of non-dash cells).

2) C3 doesn't return anything because the character above is a dash.
3) B3 returns 4 because (B2+D2+E2)/A2 = (0+8+4)/3 = 4.

I have found a solution for 1) and 2).

Code:
=IF(B2<>"-",AVERAGE(OFFSET(A2,0,1,1,$A2)),"")

IF(B2<>"-" solves 1), and AVERAGE(OFFSET(A2,0,1,1,$A2)) solves 2).

Does anyone have a solution for 3) ?
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,216,099
Messages
6,128,819
Members
449,469
Latest member
Kingwi11y

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