VBA to override formula in cell

MariahLeach

New Member
Joined
Jan 27, 2022
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

Looking for some help in VBA.

I want to be able to tick a box, and when ticked I would like a new formula to override a cell. When unticked, would like to have the original formula in the cell calculate

The original cell formula calculates a new Value based off of a hardcoded percentage you manually input.

The original formula for H9 is: =IFERROR(IF(OR(G11>0%,G11=0),G11*C$4,""), "") - G is the percentage you manually input - C4 is the overall value of the account

If I tick the box I would like the formula for H9 to be: =IFERROR(SUM(D11/$C$4),"")

Any ideas on writing a code? I need to create this option individually for 100 cells

Thanks in advance!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
There is no way to restore the edited value unless you store it somewhere. No idea if you intend that to be in code, which won't work unless the variable holding the formula remains in scope after the procedure runs, or if you'll store it somewhere else in the workbook. Might be easier if some cell in the row contained a trigger value and the formula just used IF(cell address = TriggerValue, then formula(1), else formula(2))? Do you really need the OR? Wouldn't IF >= 0 work?
 
Upvote 0
What do you mean "tick a box"? Is it a "check box"? Does it come from "form controls" or "ActiveX Controls"?
Untitled.png
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,955
Latest member
BatCoder

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