Message Box Warning

Fitzhay

Active Member
Joined
Jun 10, 2005
Messages
486
I have recorded two macros and attached them to buttons on the sheet. The first macro is for an advanced filter in place and the second is to show all the data again.

If someone clicks on the restore button BEFORE running the advanced filter the Microsoft Visual Basic box opens with runtime error '1004' displayed and the message "ShowAllData method of Worksheet class failed" and displaying three active buttons 'End', 'Debug' and 'Help"

The macro code is:

Sub Restore()

ActiveSheet.ShowAllData

End Sub

I would like a warning box to pop up on clicking the Restore button BEFORE running the filter to say

"you MUST click on the SEARCH button BEFORE clicking on the RESTORE button"

Any help gratefully received!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Code:
Sub Restore()

On Error GoTo Hell

ActiveSheet.ShowAllData

Hell:
MsgBox("you MUST click on the SEARCH button BEFORE clicking on the RESTORE button")

End Sub
 
Upvote 0
ShowAllData is one of the buttons availiable from Tools>Customize>Customize Toolbars>Commands. It greys out when the sheet is unfiltered.
 
Upvote 0
Thanks Sal for the code. While it works it also brings the message box up when the sheet has been filtered. I guess I need something that checks if the sheet is filtered and then returns the message when it finds that it isn't filtered. Is this possible??

Thanks for the help.
 
Upvote 0
Thanks for that Yard. Did the trick nicely!

Thank you all for your help, I appreciate it.
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,747
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top