Question regarding Checkboxes changing formulas in cells?

msmith012776

New Member
Joined
Mar 30, 2024
Messages
7
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet that I use to keep track of payments made. I have a cell(B3) that contains the formula "=E7+E8+E9+E10+E11+E12+E13". Curious if I can use a checkbox to when checked change the formula to, let say for example "=E8+E9+E10+E11+E12+E13" to remove an entry from the formula.

I tried this when clicked.

If B3 = "=E7+E8+E9+E10+E11+E12+E13" Then 'Nothing checked yet.
B3 , "=E8+E9+E10+E11+E12+E13", ""

I get no errors but nothing happens??

Whole code below sorry for the length there is 6 checkboxes that will need to be removed and checked against? Maybe I'm going about this the wrong way. Just trying to reduce human error. Code is trying to catch all scenarios of check box combinations. Everything below the If was my original attempt which did error out. The IF statement I've been messing with trying different things.

Thank you for your time and suggestions.

Private Sub CheckBox20_(Click)
If B3 = "=E7+E8+E9+E10+E11+E12+E13" Then 'Nothing checked yet.
B3 , "=E8+E9+E10+E11+E12+E13", ""

ElseIf B3.Value = "=E7+E9+E10+E11+E12+E13" Then 'E8 checked only.
B3.Value = "=E9+E10+E11+E12+E13"

ElseIf B3.Value = "=E7+E8+E10+E11+E12+E13" Then 'E9 checked only.
B3.Value = "=E8+E10+E11+E12+E13"

ElseIf B3.Value = "=E7+E8+E9+E11+E12+E13" Then 'E10 Checked Only.
B3.Value = "=E8+E9+E11+E12+E13"

ElseIf B3.Value = "=E7+E8+E9+E10+E12+E13" Then 'E11 Checked Only.
B3.Value = "=E8+E9+E10+E12+E13"

ElseIf B3.Value = "=E7+E8+E9+E10+E11+E13" Then 'E12 Checked Only.
B3.Value = "=E8+E9+E10+E11+E13"

ElseIf B3.Value = "=E7+E8+E9+E10+E11+E12" Then 'E13 Checked Only.
B3.Value = "=E8+E9+E10+E11+E12"
'************************************************************************
ElseIf B3.Value = "=E7+E10+E11+E12+E13" Then ' E8 & E9 Checked.
B3.Value = "=E10+E11+E12+E13"

ElseIf B3.Value = "=E7+E9+E11+E12+E13" Then ' E8 & E10 Checked.
B3.Value = "=E9+E11+E12+E13"

ElseIf B3.Value = "=E7+E9+E10+E12+E13" Then ' E8 & E11 Checked.
B3.Value = "=E9+E10+E12+E13"

ElseIf B3.Value = "=E7+E9+E10+E11+E13" Then ' E8 & E12 Checked.
B3.Value = "=E9+E10+E11+E13"

ElseIf B3.Value = "=E7+E9+E10+E11+E12" Then ' E8 & E13 Checked.
B3.Value = "=E9+E10+E11+E12"

ElseIf B3.Value = "=E7+E8+E11+E12+E13" Then ' E9 & E10 Checked.
B3.Value = "=E8+E11+E12+E13"

ElseIf B3.Value = "=E7+E8+E10+E12+E13" Then ' E9 & E11 Checked.
B3.Value = "=E8+E10+E12+E13"

ElseIf B3.Value = "=E7+E8+E10+E11+E13" Then ' E9 & E12 Checked.
B3.Value = "=E8+E10+E11+E13"

ElseIf B3.Value = "=E7+E8+E10+E11+E12" Then ' E9 & E13 Checked.
B3.Value = "=E8+E10+E11+E12"

ElseIf B3.Value = "=E7+E8+E9+E12+E13" Then ' E10 & E11 Checked.
B3.Value = "=E8+E9+E12+E13"

ElseIf B3.Value = "=E7+E8+E9+E11+E13" Then ' E10 & E12 Checked.
B3.Value = "=E8+E9+E11+E13"

ElseIf B3.Value = "=E7+E8+E9+E11+E12" Then ' E10 & E13 Checked.
B3.Value = "=E8+E9+E11+E12"

ElseIf B3.Value = "=E7+E8+E9+E10+E13" Then ' E11 & E12 Checked.
B3.Value = "=E8+E9+E10+E13"

ElseIf B3.Value = "=E7+E8+E9+E10+E12" Then ' E11 & E13 Checked.
B3.Value = "=E8+E9+E10+E12"

ElseIf B3.Value = "=E7+E8+E9+E10+E11" Then ' E12 & E13 Checked.
B3.Value = "=E8+E9+E10+E11"
'************************************************************************
ElseIf B3.Value = "=E7+E11+E12+E13" Then 'E8 & E9 & E10 Checked.
B3.Value = "=E11+E12+E13"

ElseIf B3.Value = "=E7+E10+E12+E13" Then 'E8 & E9 & E11 Checked.
B3.Value = "=E10+E12+E13"

ElseIf B3.Value = "=E7+E10+E11+E13" Then 'E8 & E9 & E12 Checked.
B3.Value = "=E10+E11+E13"

ElseIf B3.Value = "=E7+E10+E11+E12" Then 'E8 & E9 & E13 Checked.
B3.Value = "=E10+E11+E12"
'************************************************************************
ElseIf B3.Value = "=E7+E09+E12+E13" Then 'E8 & E10 & E11 Checked.
B3.Value = "=E9+E12+E13"

ElseIf B3.Value = "=E7+E09+E11+E13" Then 'E8 & E10 & E12 Checked.
B3.Value = "=E9+E11+E13"

ElseIf B3.Value = "=E7+E09+E11+E12" Then 'E8 & E10 & E13 Checked.
B3.Value = "=E9+E11+E12"
'************************************************************************
ElseIf B3.Value = "=E7+E09+E10+E13" Then 'E8 & E11 & E12 Checked.
B3.Value = "=E9+E10+E13"

ElseIf B3.Value = "=E7+E09+E10+E12" Then 'E8 & E11 & E13 Checked.
B3.Value = "=E9+E10+E12"
'************************************************************************
ElseIf B3.Value = "=E7+E12+E13" Then 'E8 & E9 & E10 & E11 Checked.
B3.Value = "=E12+E13"

ElseIf B3.Value = "=E7+E11+E13" Then 'E8 & E9 & E10 & E12 Checked.
B3.Value = "=E11+E13"

ElseIf B3.Value = "=E7+E11+E12" Then 'E8 & E9 & E10 & E13 Checked.
B3.Value = "=E11+E12"
'************************************************************************
ElseIf B3.Value = "=E7+E8" Then 'E9 & E10 & E11 & E12 & E13 Checked.
B3.Value = "=E8"

ElseIf B3.Value = "=E7+E9" Then 'E8 & E10 & E11 & E12 & E13 Checked.
B3.Value = "=E9"

ElseIf B3.Value = "=E7+E10" Then 'E8 & E9 & E11 & E12 & E13 Checked.
B3.Value = "=E10"

ElseIf B3.Value = "=E7+E11" Then 'E8 & E9 & E10 & E12 & E13 Checked.
B3.Value = "=E11"

ElseIf B3.Value = "=E7+E12" Then 'E8 & E9 & E10 & E11 & E13 Checked.
B3.Value = "=E12"

ElseIf B3.Value = "=E7+E13" Then 'E8 & E9 & E10 & E11 & E12 Checked.
B3.Value = "=E13"
'************************************************************************
Else
B3.Value = "=0"

End If
End Sub
 
Well, I'm glad I was able to impart some kind of benefit to the outcome. It seems to me that you arrived at a simpler solution than where I thought this might go, and that's a bonus. I have to admit that I'm not completely digesting your solution, but after all it's late here now and I'm out of steam!
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
So basically the statement in the J column states that if the I Column (the cb's) is True then result is 0 if its false then its the amount shown in the E column. Then I used SUM in B3 to add the J column up. This way I don't have to change the formula in B3 ever.
 
Upvote 0
Got it, thanks. I guess that's why they call it a helper column. :)
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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