Prevent ShowAllData Method from failing
Thanks Dave and OssieMac, I tried both solutions and they did exactly what I
wanted.
"OssieMac" wrote:
Hi again Jim,
The following method of testing both AutoFilterMode and FilterMode together
in the one If statment also works.
Note there is no need to use = True because it is understood. (If testing
for False then you use = False)
Also I think your use of ElseIf and Else is not correct. I think the Else
part will never be processed under any conditions.
Note the space and underscore at the end of a line is a line break in an
otherwise single line of code. (I used them extensively when posting here
because it prevents unwanted line breaks in the post and the code can be
copied directly into your project.
Sub UnhideBlanks()
'
' UnhideBlanks Macro
'
ActiveSheet.Unprotect Password:="sivle"
If ActiveSheet.AutoFilterMode _
And ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
ElseIf ActiveSheet.AutoFilterMode = False Then
ActiveSheet.Protect Password:="sivle", _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
AllowSorting:=True, _
AllowFiltering:=True
End If
End Sub
--
Regards,
OssieMac
|