I am working on a vba excel userform and I am stuck at a point where a textbox named "Textbox6" won't update when certain conditions are in place - Like a option button selected or not.
In other words. If Optionbuttton10 is true "only" then Textbox6 displays the value in Cell D3
If "OptionButton10" is true AND "Optionbutton2" is True then I want Textbox6 to display the cell E3
This is the code I have so far and it "looks" like it should work but I am missing something.
Private Sub OptionButton10_Click()
Dim D3 As Variant
Dim E3 As Variant
D3 = Sheets("Systems").Range("D3").Value
E3 = Sheets("Systems").Range("E3").Value
If OptionButton10 = True And ComboBox2 = "Standard" Or ComboBox2 = "Scale-In" Then
TextBox6.Value = D3 'this works'
ElseIf OptionButton10 = True And OptionButton2 = True Then
TextBox6.Value = E3 'this doesn't work'
End If
TextBox6.Text = Format(TextBox6.Value, "Percent")
End Sub
The solution that worked for me is below.
I used a nested If statement and added the "optionbutton2 = false"
Private Sub OptionButton10_Click()
Dim D3 As Variant
Dim E3 As Variant
D3 = Sheets("Systems").Range("D3").Value
E3 = Sheets("Systems").Range("E3").Value
If ComboBox2 = "Standard" Or ComboBox2 = "Scale-In" Then
If OptionButton10 = True And OptionButton2 = False Then
TextBox6.Value = D3
ElseIf OptionButton10 = True And OptionButton2 = True Then
TextBox6.Value = E3
End If
End If
TextBox6.Text = Format(TextBox6.Value, "Percent")
End Sub