J
JimAA
Hi,
I have an Excel 2007 worksheet that has autofilters and macros assigned to
option buttons in a Group Box that carry out some of the filtering. One
button is the ShowAllData button that removes the filter. If the ShowAllData
button is selected and then selected again (before any other button in the
group is selected) I get a Run Time Error that the ShowAllData method of
worksheet class failed. How do I prevent this error? I'm very new to VB.
The code below is what I'm having trouble with.
Thanks,
Jim
Sub UnhideBlanks()
'
' UnhideBlanks Macro
'
ActiveSheet.Unprotect Password:="sivle"
If ActiveSheet.AutoFilterMode = True Then
ActiveSheet.ShowAllData
ElseIf ActiveSheet.AutoFilterMode = False Then
Else
ActiveSheet.Protect Password:="sivle", DrawingObjects:=True,
Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
End If
End Sub
I have an Excel 2007 worksheet that has autofilters and macros assigned to
option buttons in a Group Box that carry out some of the filtering. One
button is the ShowAllData button that removes the filter. If the ShowAllData
button is selected and then selected again (before any other button in the
group is selected) I get a Run Time Error that the ShowAllData method of
worksheet class failed. How do I prevent this error? I'm very new to VB.
The code below is what I'm having trouble with.
Thanks,
Jim
Sub UnhideBlanks()
'
' UnhideBlanks Macro
'
ActiveSheet.Unprotect Password:="sivle"
If ActiveSheet.AutoFilterMode = True Then
ActiveSheet.ShowAllData
ElseIf ActiveSheet.AutoFilterMode = False Then
Else
ActiveSheet.Protect Password:="sivle", DrawingObjects:=True,
Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
End If
End Sub