Calculating a moving average and deleting the cell (and moving the rest of the cells underneath up)

KelvinLGW

New Member
Joined
Jul 1, 2016
Messages
15
Hi,

So what I'm after is creating a vba code to calculate the 10 period moving average of the data in column B (but this is done in the background, I don't want it to write it down anywhere) it then tests if that moving average value is greater than or equal to 0.05, if the value is below 0.05 then the cell in column B is deleted and the rest of the cells are moved upwards leaving column A untouched. This keeps going on until a moving average of 0.05 or greater is achieved, the code then stops at that point.

I then want to extend this further to run through columns C, D, E, etc (depending on how many columns there are - of which the code should be able to detect automatically)

Attached is a picture to help understand the problem better.

TimeDataMoving AverageMoving average >= 0.05?
00.00456458384786362
0.003902494

<tbody>
</tbody>
No
0.01-0.00515633489750567
0.003778908

<tbody>
</tbody>
No
0.020.00559841936280558
0.004158014

<tbody>
</tbody>
No
0.030.0191360829834526
0.003360237

<tbody>
</tbody>
No

<tbody>
</tbody>


In this case I don't want columns C and D to show (Moving average & Moving average >= 0.05? respectively)

Any help would be much appreciated.

Thanks,

Kelvin Lee
 
Last edited:

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,214,834
Messages
6,121,873
Members
449,056
Latest member
ruhulaminappu

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