How can I get a macro to know when it false and run a different ma

G

Guest

If the macro / code turns out to be an error Then run a different macro.

The code is:
ActiveSheet.ShowAllData

but if it is already showing all then the macro shuts down with an error
message.
Instead I want it to realize it doesn’t work and run a different macro
instead.
 
G

Guest

Showall data fails becuase you don't have aoutfiltering on. You need to test
for auto filtering as follows:

Sub test()

With ActiveSheet
If .AutoFilterMode Then
.ShowAllData
Else
' enter your alternate code
End If
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top