VBA - override autofilter warning message

no_Fate

New Member
Joined
Jan 22, 2015
Messages
6
Good evening guys,

Just a quick (I hope) question:
I'm creating a tool to use at work. It will essentially perform an autofilter operation.
The thing is that I want the results to be only 5, so that's the limit I have in my destination range and, if by any inexplicable reason, someone search for half the number they're supposed to, the number of results will be high... if this happens the message "The destination range is not large enough to accommodate all copied rows. Data below the destination range will be lost. Continue copying anyway?" is displayed.

All this to ask: Is it possible to override this message? (I need other to be displayed if other conditions are meet, so I cannot use the "DisplayAlerts = False" code. Or is there any way for the code always answer "No" to this question?

Thank you.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi no_Fate,

I'd suggest you write the VBA code so that it checks the number of filtered rows against the maximum number of destination rows. That allows you to control any user warning message and next action to be taken.

If you are using the AdvancedFilter function, then I'd suggest writing the filter results to a temporary sheet. That will allow you to preview the results before attempting to copy them to the destination.
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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