View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Determined if filtered range is empty

Hi
try the following
Sub foo()
Dim rng As Range
Set rng = Selection

rng.AutoFilter Field:=3, Criteria1:="Household"
Set rng = ActiveSheet.AutoFilter.Range
If rng.Columns(1).SpecialCells(xlVisible).Count - 1 = 0 Then
MsgBox "no rows to display"
End If
End Sub

This returns a message if now rows are returned by your criteria


--
Regards
Frank Kabel
Frankfurt, Germany

Fred Smith wrote:
I am setting an Autofilter with:

Selection.AutoFilter Field:=3, Criteria1:=Household

However, sometimes Household doesn't exist in the table. How do I
test to see if the selected range is empty? Is there a way to test
whether Household exists in the Criteria1 list? Or is there a test to
see if the Autofilter.Range is empty?