Help with checkbox click event...

rlink_23

Board Regular
Joined
Oct 30, 2015
Messages
149
I have my project working great except for one detail that I missed, I am shaking my head in disbelief that I did so. And now I don't know how to proceed. So long story short I have an Userform that totals 4 textboxs and and puts the total in the Total textbox. Then lastly I have a textbox that appears that is the total plus tax when checkBox = True. The problem I have is when I save to Sheet1. It saves the total in column F. Well I failed to figure out how to Save the total With Tax instead when it is clicked with tax.. In a perfect world I would like the Total to disappear when the total with Tax appears and it saves the total with Tax. But I may not get so lucky haha.... Anyways I hope someone can help!


So code that saves to sheet

Code:
Private Sub CommandButton5_Click()   Dim rw As Long    'next available row
 
   With Sheets("Sheet1")
 
      'get the next available row in Sheet1
      rw = .Range("B" & .Rows.Count).End(xlUp).Row + 1
      'put the text box values in this row
      'put the text box values in this row
      .Range("B" & rw).Value = TextBox1.Value
      .Range("C" & rw).Value = TextBox2.Value + " " + TextBox4.Value + " " + TextBox5.Value
      .Range("E" & rw).Value = TextBox11.Value
      .Range("H" & rw).Value = TextBox7.Value + " " + TextBox8.Value
      .Range("I" & rw).Value =  TextBox9.Value
      .Range("M" & rw).Value = TextBox10.Value
      .Range("F" & rw).Value =  TextBox6.Value
      .Range("J" & rw).Value =  TextBox12.Value
      .Range("K" & rw).Value = TextBox13.Value
      .Range("L" & rw).Value =  TextBox14.Value
      .Range("O" & rw).Value = TextBox15.Value
      .Range("D" & rw).Value = TextBox16.Value
      .Range("G" & rw).Value = TextBox17.Value
      
 End With
 
  
   TextBox1.Value = Clear
   TextBox2.Value = Clear
   TextBox4.Value = Clear
   TextBox5.Value = Clear
   TextBox6.Value = Clear
   TextBox7.Value = Clear
   TextBox8.Value = Clear
   TextBox9.Value = Clear
   TextBox10.Value = Clear
   TextBox11.Value = Clear
   TextBox12.Value = Clear
   TextBox13.Value = Clear
   TextBox14.Value = Clear
   TextBox15.Value = Clear
   TextBox16.Value = Clear
   TextBox17.Value = Clear
   TextBox18.Value = Clear
   TextBox19.Value = Clear
   
End Sub


Then I have the Check Box Click event
Code:
Private Sub CheckBox1_Click()

For Each Objctrl In Me.Controls
If Left(Objctrl.Name, 4) = "Text" Then Objctrl.Visible = CheckBox1.Value
Next
If CheckBox1 = True Then
 TextBox6.Value = Cost.Value * 1.088
 TextBox6.Value = Format(TextBox6.Value, "$#,##0.00")
 Else
 CheckBox1 = False
 TextBox6.Value = ""
 
 End If


   End Sub



Also I am guessing there is a better way of doing the coding I did but please don't make fun of me hahaha :laugh::laugh::laugh:
 
Last edited:
So now you want a script to sum all the values in visible Textboxes. Is that true.

Please give me the names of the textboxes you want added up.

I asked you this earlier but you never gave me a answer.

What is the name of the textbox that may not be visible?
 
Last edited:
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
No I have that done already. I was thinking outloud. I was thinking if on my userform if CheckBox1 is True then it would only show TextBox6(subtotal) (TextBox7(subtotal + Tax) disappears), Then if checkbox1 is False it would show TextBox 7 (TextBox6 disappears). The problem is the "Total" Is in Sheet1 and I would need the total that is visible to transfer to Row F +1 So it moves to the next row...
 
Upvote 0
It's just a process of writing if statements.
Like if Checkbox1.value=true then Textbox1.visible= True

Like this:
Code:
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
TextBox1.Visible = True
Else
TextBox1.Visible = False
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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