ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help! Need quick answer how to handle no data condition for filter (https://www.excelbanter.com/excel-programming/329583-help-need-quick-answer-how-handle-no-data-condition-filter.html)

davegb

Help! Need quick answer how to handle no data condition for filter
 
I'm on a short deadline, so I need help right away if possible. I have
a macro creating an advanced filter that extracts data from a hidden
datasheet based on a selected cell in a source sheet. On previous
sheets, I tested for data to filter using info on the source sheet, but
I have a new source sheet that doesn't have the info on it. Is there a
way to trap the filter results if there is no applicable data and send
it to the MsgBox I already created that says there's no revelant data
for that county? Right now, I'm getting a macro error 1004,
"Application defined or object defined error" when it tries to apply
the filter.
Thanks for the help!


Darrin Henshaw

Help! Need quick answer how to handle no data condition for filter
 
Some error trapping should work, something like:

On Error GoTo ErrorHandler

And then:

ErrorHandler:
'code for msgbox

That should work.



*** Sent via Developersdex http://www.developersdex.com ***

Bob Phillips[_6_]

Help! Need quick answer how to handle no data condition for filter
 
I don't know how you extract the filtered data, but I use code like

Set rng = rngToFilter.SpecialCells(xlCellTypeVisible)

so you can test that for Nothing

If Not rng Is Nothing Then

etc.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"davegb" wrote in message
oups.com...
I'm on a short deadline, so I need help right away if possible. I have
a macro creating an advanced filter that extracts data from a hidden
datasheet based on a selected cell in a source sheet. On previous
sheets, I tested for data to filter using info on the source sheet, but
I have a new source sheet that doesn't have the info on it. Is there a
way to trap the filter results if there is no applicable data and send
it to the MsgBox I already created that says there's no revelant data
for that county? Right now, I'm getting a macro error 1004,
"Application defined or object defined error" when it tries to apply
the filter.
Thanks for the help!





All times are GMT +1. The time now is 02:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com