PDA

View Full Version : Option Button first IF not working.....



Mr.G
06-03-2009, 05:01 AM
Just wondering why does the first option button call the msgbox? It should select the offset.

Private Sub CommandButton1_Click()

If OptionButtion1 Then
ActiveCell.Offset(0, 2).Activate
ElseIf OptionButton7 Then
ActiveCell.Offset(, 3).Activate
ElseIf OptionButton6 Then
ActiveCell.Offset(, 4).Activate
ElseIf OptionButton5 Then
ActiveCell.Offset(, 5).Activate
ElseIf OptionButton4 Then
ActiveCell.Offset(, 6).Activate
ElseIf OptionButton3 Then
ActiveCell.Offset(, 7).Activate
ElseIf OptionButton9 Then
ActiveCell.Offset(, 8).Activate
ElseIf OptionButton13 Then
ActiveCell.Offset(, 9).Activate
ElseIf OptionButton12 Then
ActiveCell.Offset(, 10).Activate
ElseIf OptionButton11 Then
ActiveCell.Offset(, 11).Activate
ElseIf OptionButton10 Then
ActiveCell.Offset(, 12).Activate
ElseIf OptionButton8 Then
ActiveCell.Offset(, 13).Activate
Else
MsgBox "Please select one"
End If
TextBox1 = ActiveCell.Value

End Sub

Thank you

p45cal
06-03-2009, 05:17 AM
spell OptionButtion1 correctly and you should be OK

Mr.G
06-03-2009, 05:32 AM
Double post

Mr.G
06-03-2009, 05:36 AM
:banghead: Ouch...didn't even see that.....
I need a hiding for that.:bonk:

Thanks

JONvdHeyden
06-03-2009, 05:39 AM
Since you're only using values 1 thru 12 consider using a list box instead.

Drop a listbox onto your form.
Change the ListStyle to 1 - frmListSyleOption
Change the Backcolor to &H8000000F&
Change the SpecialEffect to 0 - frmSpecialEffectFlat

On Useform Initialize add items to the listbox 1 thru 12.

Change CommandButton1_Click to:

ActiveCell.Offset(, Me.ListBox1.Value).Activate

mikerickson
06-03-2009, 05:39 AM
Option Explcit is useful tool