VBA to remove / add formula to cells

Akira181

Board Regular
Joined
Mar 23, 2010
Messages
67
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet where Sheet1, Column L has a formula to calculate a budget. Once the budget is set, I recorded a macro and assigned to a FormControl button to remove the formulas to "freeze" the budget. The macro basically copies the column, pastes the column (formulas included) into Sheet2 and then pastes only the values back into Sheet1, Column L.

There is also a reset button, if you want to "unfreeze" the budget and recalculate. It copies the column from Sheet2 and pastes back into Sheet1 to reinstate the formulas.This recorded macro is also assigned to a FormControl button if that makes a difference.

The problem I'm having is that if the user inserts new rows into the table in Sheet1 AFTER the budget has been frozen, when they click the reset button, the cells in the copied Column L in Sheet2 no longer align after any inserted rows.

Is this something that can be done with VBA without using the copy&paste route to avoid the inserting rows issue?

To make it a little more confusing, the column contains 2 formulas. First one is in the majority of cells and the second is only when there is a "Subtotal" in the adjacent cell in Column K. The range goes from row 4 to row 52.

Excel Formula:
=IF(AND(F8="Weeks",J8="Per Day"),H8*I8*K8*7,I8*K8)

Excel Formula:
=SUMIFS(L8:L12,$K$8:$K$12,"<>Subtotal")
 
Last edited:

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
bump, anyone?

*edit, sorry if bumping a post isn't allowed. Realised I should have checked the forum rules after I hit post
 
Upvote 0

Forum statistics

Threads
1,214,575
Messages
6,120,344
Members
448,956
Latest member
Adamsxl

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