checkbox reverting back to original state

rlink_23

Board Regular
Joined
Oct 30, 2015
Messages
149
I am building an userform That has 5 textboxes that will have pricing in them which I have VBA already set up as follows


TextBox1 (price) + Textbox2 (deposit) = TextBox3 (Subtotal)

Which I'm not sure if this is right but TextBox3 (subtotal) and Textbox 5 (Grand total) are the same unless TextBox4 (insurance) has data entered and then it would be
TextBox 3 (Subtotal) + Textbox4 (insurance) = TextBox5 (Grand total)

That is not where the problem lies though. I added a checkbox to calculate tax and that part works, but I cannot for the life of me to get it to revert back to the original state when it unchecked. The code I have inserted is as follows

Code:
Private Sub CheckBox1_Click()If CheckBox1 = True Then
 Cost.Value = Cost.Value * 1.088
 
 End If
  If CheckBox1 = False Then
Cost.Text = Subtotal.Value + Insurance.Value


End If


   End Sub



We all know what is happening on uncheck it just literally adds the numbers in the 2 textboxes together :laugh::laugh: But I have tried everything I can think of and I have yet to figure it out... That is when I turn to you guys.. I am hoping someone can help.. I try not to use the forums too much but in this case I cannot finish the project without your help!! :)
Thanks in advance for the help and I hope this is easily understandable
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Please explain a little more what your wanting please
 
Last edited:
Upvote 0
It seems to me that you are changing the Cost.Value with the checkbox. Unchecking it will not change the value back. Why not add another text box for TAX and if the checkbox is true then tax = cost.value * 1.088. if checkbox = false then tax = 0
 
Upvote 0
Reversing the actions a script has performed is difficult unless you store the original values some place.
 
Upvote 0
Code:
Private Sub CheckBox1_Click()
If CheckBox1 Then
    TaxBox.Value = Cost.Value * 1.088
Else
    TaxBox.Value = 0
End If
End Sub

Translation: The checkbox is Boolean therefore the code reads:
If Checkbox1 = True, then
do something
or Else if
Checkbox1 = False then
do this instead
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
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