L
LEU
I have the following macro (First set) that when you check a box it puts a
number in a textbox and then totals all the textboxes. It works if I check a
box, but if I make a mistake and uncheck that box and check a new box it
doesn't correct the number in the textbox. I have 10 sets of 5 checkboxes
that I add up.
Private Sub CheckBox1_Click()
For i = 2 To 5
If CheckBox1.Value = True Then
Me.Controls("CheckBox" & i) = False
Me.Controls("CheckBox" & i).Enabled = False
Else
Me.Controls("CheckBox" & i).Enabled = True
End If
Next i
If CheckBox1 = True Then
TNbr1 = "1"
TextBox100 = TNbr1
ElseIf CheckBox2 = True Then
TNbr1 = "2"
TextBox100 = TNbr1
ElseIf CheckBox3 = True Then
TNbr1 = "3"
TextBox100 = TNbr1
ElseIf CheckBox4 = True Then
TNbr1 = "4"
TextBox100 = TNbr1
ElseIf CheckBox5 = True Then
TNbr1 = "5"
TextBox100 = TNbr1
End If
TextBox110 = (TNbr1 + TNbr2 + TNbr3 + TNbr4 + TNbr5 + _
TNbr6 + TNbr7 + TNbr8 + TNbr9 + TNbr10)
End Sub
number in a textbox and then totals all the textboxes. It works if I check a
box, but if I make a mistake and uncheck that box and check a new box it
doesn't correct the number in the textbox. I have 10 sets of 5 checkboxes
that I add up.
Private Sub CheckBox1_Click()
For i = 2 To 5
If CheckBox1.Value = True Then
Me.Controls("CheckBox" & i) = False
Me.Controls("CheckBox" & i).Enabled = False
Else
Me.Controls("CheckBox" & i).Enabled = True
End If
Next i
If CheckBox1 = True Then
TNbr1 = "1"
TextBox100 = TNbr1
ElseIf CheckBox2 = True Then
TNbr1 = "2"
TextBox100 = TNbr1
ElseIf CheckBox3 = True Then
TNbr1 = "3"
TextBox100 = TNbr1
ElseIf CheckBox4 = True Then
TNbr1 = "4"
TextBox100 = TNbr1
ElseIf CheckBox5 = True Then
TNbr1 = "5"
TextBox100 = TNbr1
End If
TextBox110 = (TNbr1 + TNbr2 + TNbr3 + TNbr4 + TNbr5 + _
TNbr6 + TNbr7 + TNbr8 + TNbr9 + TNbr10)
End Sub