Placing values in a cell using checkbox macro

kwroche

New Member
Joined
Jun 18, 2008
Messages
16
I have a checkbox macro that calls a macro when its on and calls a different macro when its off. The macro is as follows:

Sub OxygenCheckBox()
Dim cb As Excel.CheckBox


Set cb = Excel.ActiveSheet.CheckBoxes(Application.Caller)
If cb.Value = xlOn Then
Call YesOxygen
Else
Call Oxygen
End If

in addition to calling these macros, I want the checkbox to place "0" in a range of cells when checked (E280:E285), and when unchecked I want cells E280:E285 to display its normal formulas. Is there anyway to do this? Thank you for any help.
 

Some videos you may like

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

kwroche

New Member
Joined
Jun 18, 2008
Messages
16
yes i can, I just don't know how I would do the code for that, I've tried a number of things but it won't work. Sorry, I should of clarified it more clearly what I need. I need the code for a macro to do what I talked about earlier.
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Putting zero in the cells is easy:

Range("E280:E285").Value = 0

The formula would probably also be easy if I knew what it was.

An alternative is to change your formulas in E280:E285 so that they return 0 if the CheckBox's LinkedCell contains TRUE.
 

kwroche

New Member
Joined
Jun 18, 2008
Messages
16

ADVERTISEMENT

ooo, thats a good idea.

Ok, tell me what to fix with this then...
=if(check box 62=true,0,"formula")
this doesn't work as I am unsure of how to check to see whether a check box value is on or not in a cell formula. Could you help me out on that one?
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Set the CheckBox's LinkedCell property to some spare cell. Then use that cell in your IF formula.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,418
Messages
5,596,024
Members
414,037
Latest member
Roamingsmile

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
Top