Hi
I am having a problem with this piece of code even after i set the LookIn:=xlFormulas and removed LookAfter. Basically, first the program would hide the data within a selected range then unhide the column that match the caption. The code has no problem when i don't hide the data. But when i hide the data It gives me this error Run-time error '91' Object variable or with block variable not set. Could anyone help me out Below is the code
Private Sub CommandButton1_Click() 'This is for the "OK" button
'Declare variables to hold the value of caption
Dim Sheet As String
'Assign variables, Declare active sheet and range
Sheet = "General"
Worksheets(Sheet).Select
' Hide all data within range
Range("P10:AV254").EntireColumn.Hidden = True
' Begin your Selection
If CheckBox1.Value = True Then
Range("P10:AV254").Select
Cells.Find(What:=CheckBox1.Caption, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False).EntireColumn.Select
'Want to unhide a particular column base on
Columns(ActiveCell.Column).EntireColumn.Hidden = False
End If
End Sub