Macros - Editing your own error message

Anonymous321

New Member
Joined
Oct 12, 2021
Messages
32
Office Version
  1. 365
Platform
  1. Windows
Hi
I'm wondering if there is a way to add your own error message to a macro I have assigned to a button.
The button merely just removes any filters present in the sheet. If the button is pressed without any filters being present it comes up with abit of a messy error message. I'm wondering if theres a way to change this error message so it reads whatever I want it too.

The code in question:
Sub Remove_Filters()
'
' Remove_Filters Macro
'

'
ActiveSheet.ShowAllData
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Best option is to prevent the error in the first place.
VBA Code:
If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,937
Members
448,534
Latest member
benefuexx

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