If filtered range is blank, message box

Afro_Cookie

Board Regular
Joined
Mar 17, 2020
Messages
103
Office Version
  1. 365
Platform
  1. Windows
I filter my data based on entries in field 8 and once I have that filtered I want a message box to pop up to let me know if there are any new entries.

The filtering works, and I know that the message box criteria is wrong since cell H2 won't be blank. It's just not in the filtered range, but I'm not sure how to format my message box correctly to only prompt if no values were filtered. Can someone please help me with this?
VBA Code:
Sub mmsn()

ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=8, _
    Criteria1:=Array("36011771", "36011857", "36000007", "36001281", "36000695"), Operator:=xlFilterValues

If ActiveSheet.Range("$H2").Value = "" Then
    MsgBox "There are no new entries", vbOKCancel
    Exit Sub
End If

End Sub

Book1
ABCDEFGHI
1abcdefghi
2123456789
3123456789
4123456789
Sheet1
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Do you want the message box if all the data is hidden?
 
Upvote 0
Do you want the message box if all the data is hidden?
in an ideal case, if all the data is hidden, it means there are no new entries in field 8 which would then trigger the message box.
 
Upvote 0
Ok, how about
VBA Code:
With ActiveSheet.ListObjects("Table1").Range
   .AutoFilter Field:=8, _
    Criteria1:=Array("36011771", "36011857", "36000007", "36001281", "36000695"), Operator:=xlFilterValues
   If .Columns(1).SpecialCells(xlVisible).Count = 1 Then MsgBox "There are no new entries"
End With
 
Upvote 0
Solution
Ok, how about
VBA Code:
With ActiveSheet.ListObjects("Table1").Range
   .AutoFilter Field:=8, _
    Criteria1:=Array("36011771", "36011857", "36000007", "36001281", "36000695"), Operator:=xlFilterValues
   If .Columns(1).SpecialCells(xlVisible).Count = 1 Then MsgBox "There are no new entries"
End With
As always Fluff, this works and is very helpful. Thank you very much!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,046
Messages
6,128,489
Members
449,455
Latest member
jesski

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