Radio button failure

2077delta

Active Member
Joined
Feb 17, 2002
Messages
252
Office Version
  1. 365
Platform
  1. Windows
I have four radio buttons on a worksheet each set to run a certain routine. When I click on a button the first time everything works fine. The routine filters a list of data. However, if new data is added to the list and I click on the same radio button a second time to refilter the list, it fails to do anything and the focus stays on the button instead of returning to the worksheet. What is causing this and how do I fix it? The code for one of the buttons in question is below

Private Sub OSButton_Click()
Call OSChecks
End Sub

Sub OSChecks()
Dim cell1 As Range
Dim rowcount As Integer
Dim myrng As Range

Set cell1 = Range("A6")
Set cell2 = Range("A5")
rowcount = Range(cell1, cell1.End(xlDown)).Rows.Count
Set myrng = Range(cell1.Offset(0, 9), cell1(rowcount, 10))

With ActiveSheet
.AutoFilterMode = False
.Range(cell2, cell2.Offset(rowcount, 9)).AutoFilter
End With

On Error Resume Next
N = WorksheetFunction.VLookup("O/S", myrng, 1, 0)
If Err = 1004 Then
MsgBox "There are no outstanding checks"
Else
Selection.AutoFilter Field:=10
Selection.AutoFilter Field:=4, Criteria1:=""
End If
Err.Clear
On Error GoTo 0
Range("A4").Select

End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
The problem you describe is how option (radio) buttons are designed to work - you have to click another option button to deselect the current one and then that one can be clicked again.

I think four command buttons would be more appropriate from a user interface point of view and then you wouldn't have the problem. However, if you really want option buttons, try putting:

OSButton.Value = False

after Call OSChecks, and similar for the other option buttons.
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,841
Members
452,948
Latest member
UsmanAli786

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