Option Explicit
Public WithEvents Optbtn As MSForms.OptionButton
Private Sub OptBtn_Click()
Dim Fnd As Range
Set Fnd = Range("2:2").Find(Optbtn.Caption, , , xlWhole, , , False, , False)
If Not Fnd Is Nothing Then
Cells.EntireColumn.Hidden = False
If Fnd.Column > 2 Then Range("B1", Cells(1, Fnd.Column - 1)).EntireColumn.Hidden = True
End If
End Sub
Private OptBtnEvent As Collection
Private Sub UserForm_Initialize()
Dim Ctrl As MSForms.Control
Dim Obtn As ClsOptBtn
Set OptBtnEvent = New Collection
For Each Ctrl In Me.Controls
If TypeOf Ctrl Is MSForms.OptionButton Then
Set Obtn = New ClsOptBtn
Set Obtn.Optbtn = Ctrl
OptBtnEvent.Add Obtn
End If
Next
End Sub