Error Message?

  • Thread starter Thread starter hce
  • Start date Start date
H

hce

Hi

Is it possible to write a code that will generate an error message i
the filter returns 0 records? I wrote a macro to do the filter based o
the values entered in specified cells but the problem here is that som
of the criteria used might not be available hence resulting in n
records being filtered/shown... so i would like to generate an erro
message before the user sees the empty database...

cheer
 
If the number of visible cells in the first column is 1 (only the header), then
that means that there was no criteria that matched:

With ActiveSheet.AutoFilter.Range
If .Columns(1).Cells.SpecialCells(xlCellTypeVisible).Count = 1 Then
'no visible cells, except for the header
'error message here
Else
'do what you want
End if
end with
 

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

Back
Top