Remove focus from option button

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,699
Office Version
  1. 2007
Platform
  1. Windows
Hi,
This is the code for my form.

When the userform first opens i see the options of 41601 & 41835 neither of which are at this point selected.
Lets assume i select 41601 i now see the dot in the option button.
Ive noticed ive made a mistake & should of selected 41835

On the form i have a commandbutton2 which should call userform_initialize and then show me 41601 & 41835 like at the start.
This does happen BUT the incorrectly selected option in this case 41601 is shown as selected BUT i need neither to be selected


Rich (BB code):
Private Sub CommandButton1_Click()
    
 With ThisWorkbook.Worksheets("RANGER")
    If OptionButton3.Value = True Then .Cells(lastrow + 5, 9).Value = "N 41601-501-41": OptionButton3.Value = False
    If OptionButton4.Value = True Then .Cells(lastrow + 5, 9).Value = "N 41803-501-42": OptionButton4.Value = False
    If OptionButton5.Value = True Then .Cells(lastrow + 5, 9).Value = "V 41803-501-43": OptionButton5.Value = False
 
 
    With .Range("I5")
        .Font.Size = 14
        .Font.Name = "Calibri"
        .Font.Bold = True
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlVAlignCenter
    End With

    With Sheets("RANGER")
        If .AutoFilterMode Then .AutoFilterMode = False
        x = .Cells(.Rows.Count, 5).End(xlUp).Row
        .Range("A4:I" & x).Sort Key1:=Range("B5"), Order1:=xlAscending, Header:=xlGuess
    End With

    Unload RangerPcbNumber
    End With
    MsgBox "DATABASE HAS BEEN UPDATED", vbInformation, "SUCCESSFUL MESSAGE"
End Sub

Private Sub CommandButton2_Click()
Call UserForm_Initialize
End Sub

Private Sub OptionButton1_Change()
        If OptionButton1.Value = True Then
        OptionButton2.Visible = False
        OptionButton3.Visible = True
        End If
        End Sub
Private Sub OptionButton2_Change()
        If OptionButton2.Value = True Then
        OptionButton1.Visible = False
        OptionButton4.Visible = True
        OptionButton5.Visible = True
        End If
        End Sub
Private Sub OptionButton1_Click()
        If OptionButton1.Value = True Then
        OptionButton4.Visible = False
        OptionButton5.Visible = False
        End If
        End Sub
Private Sub OptionButton2_Click()
        If OptionButton2.Value = True Then
        OptionButton3.Visible = False
        End If
        End Sub
Private Sub OptionButton4_Click()
        If OptionButton4.Value = True Then
        OptionButton5.Visible = False
        End If
        End Sub
Private Sub OptionButton5_Click()
        If OptionButton5.Value = True Then
        OptionButton4.Visible = False
        End If
        End Sub
Private Sub UserForm_Initialize()
        OptionButton1.Visible = True
        OptionButton2.Visible = True
        OptionButton3.Visible = False
        OptionButton4.Visible = False
        OptionButton5.Visible = False
        End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
This works but its not the correct to do it

Rich (BB code):
Private Sub CommandButton2_Click()
Unload RangerPcbNumber
RangerPcbNumber.Show
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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