Show All Data

G

Guest

I have some quite complex filters and am trying to make the spreadsheet more
user friendly.

I have included a button to restore the Show All Data using the VBA:

ActiveSheet.ShowAllData

This works, but only if there has been a filter applied. If the user clicks
the button again (without a filter being present) I get the following error
message - "Run Time error 1004 - ShowAllData method of Worksheet class
failed".

How can I stop this error message, or better still advise the user (MSGBOX?)
that all the data is currently being shown?

Thank you for your help.
 
G

Gary Keramidas

maybe something like this

If ActiveSheet.AutoFilterMode = True Then
ActiveSheet.ShowAllData
End If
 
G

Gary Keramidas

sorry, should have posted this

If ActiveSheet.FilterMode = True Then
ActiveSheet.ShowAllData
End If
 
S

Snake Plissken

Sub Makro2()

If ActiveSheet.FilterMode = False Then
MsgBox "No filter !"
ElseIf ActiveSheet.FilterMode = True Then
ActiveSheet.ShowAllData
Else
MsgBox "unknown case"
End If


End Sub
 
Joined
Oct 9, 2009
Messages
1
Reaction score
0
Is there any way to query if any sort conditions are active on the sheet in a similar fashion to the code below? I've got a button to clear all the filters/sorts that wouldn't work if showalldata=true, so I used your little gem below and it works great. Only problem is that it will only work if a filter is present, not if just a sort has been applied. thanks



Snake Plissken said:
Sub Makro2()

If ActiveSheet.FilterMode = False Then
MsgBox "No filter !"
ElseIf ActiveSheet.FilterMode = True Then
ActiveSheet.ShowAllData
Else
MsgBox "unknown case"
End If


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

Similar Threads


Top