Auto filtering with userform

philfloyduk

Board Regular
Joined
Jan 6, 2011
Messages
82
Hi.

I have a sheet that contains invoiced work with payment status information on. I've created a form that auto filters the repairs to display unpaid work, also with the option to filter by invoice details. All works fine, but I would like a message box to pop up if there are not results found.

Below is the code on the existing form:

Private Sub cmdPDF_Click()
If cbInvoice.Value = "" Then
Sheets("invoice repairs").Range("g2").AutoFilter Field:=3, Criteria1:="No"
Else

Sheets("invoice repairs").Range("g2").AutoFilter Field:=3, Criteria1:="No"
Sheets("invoice repairs").Range("e2").AutoFilter Field:=1, Criteria1:=cbInvoice.Value
End If
Application.ActivePrinter = "PrimoPDF on Ne01:"
Sheets("invoice repairs").PrintOut From:=1, To:=1, Copies:=1, _
ActivePrinter:="PrimoPDF on Ne01:", collate:=True
Sheets("invoice repairs").Range("e2").AutoFilter Field:=1
Sheets("invoice repairs").Range("g2").AutoFilter Field:=3
End Sub

Many thanks in advance for any help given.

Phil
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Maybe:

Code:
    If Sheets("invoice repairs").AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count = 1 Then
        MsgBox "No results found"
        Exit Sub
    End If
 
Upvote 0

Forum statistics

Threads
1,224,593
Messages
6,179,791
Members
452,942
Latest member
VijayNewtoExcel

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