PDA

View Full Version : [SOLVED] Optionbutton deselection erases range value



Learner123
01-26-2011, 01:24 PM
Hello to all you masters out there!:bow:

I am having a problem with some code and was hoping to recieve some direction.

I have a userform that has two frames with several optionbuttons in each frame. I am trying to have a range populate when an optionbutton is selected. The below code does that, however, I would like the the range to delete its value when the optionbutton is deselected (by selecting another option within the frame). Not sure how to have the below code do that.:dunno

Any ideas on how to make this work??

Thank you in advance!!!!

The code I have is:


Private Sub OptionButton1_Click()
With Me
If OptionButton1.Value = True Then Range("Combo1") = "1"
End With
End Sub

Private Sub OptionButton2_Click()
With Me
If OptionButton2.Value = True Then Range("Combo1a") = "10"
End With
End Sub

Private Sub OptionButton12_Click()
With Me
If OptionButton12.Value = True Then Range("Combo1b") = "100"
End With
End Sub

Private Sub OptionButton13_Click()
With Me
If OptionButton13.Value = True Then Range("Combo1c") = "1000"
End With
End Sub

Private Sub OptionButton11_Click()
With Me
If OptionButton11.Value = True Then Range("Combo1d") = "10000"
End With
End Sub

Bob Phillips
01-26-2011, 02:34 PM
Private Sub OptionButton1_Click()
With Me
If OptionButton1.Value = True Then
Range("Combo1") = "1"
Range("Combo1a").ClearContents
Range("Combo1b").ClearContents
Range("Combo1c").ClearContents
Range("Combo1d").ClearContents
End If
End With
End Sub

Private Sub OptionButton2_Click()
With Me
If OptionButton2.Value = True Then
Range("Combo1").ClearContents
Range("Combo1a") = "10"
Range("Combo1b").ClearContents
Range("Combo1c").ClearContents
Range("Combo1d").ClearContents
End If
End With
End Sub

Private Sub OptionButton12_Click()
With Me
If OptionButton12.Value = True Then
Range("Combo1").ClearContents
Range("Combo1a").ClearContents
Range("Combo1b") = "100"
Range("Combo1c").ClearContents
Range("Combo1d").ClearContents
End If
End With
End Sub

Private Sub OptionButton13_Click()
With Me
If OptionButton13.Value = True Then
Range("Combo1").ClearContents
Range("Combo1c").ClearContents
Range("Combo1b").ClearContents
Range("Combo1c") = "1000"
Range("Combo1d").ClearContents
End If
End With
End Sub

Private Sub OptionButton11_Click()
With Me
If OptionButton11.Value = True Then
Range("Combo1").ClearContents
Range("Combo1a").ClearContents
Range("Combo1b").ClearContents
Range("Combo1c").ClearContents
Range("Combo1d") = "10000"
End If
End With
End Sub

Learner123
01-28-2011, 12:06 PM
That's a score. Thank you!

http://www.freesmileys.org/smileys/smiley-sport004.gif (http://www.freesmileys.org/smileys.php)