R
RyanH
I have a large list of products that are in production on a worksheet. Each
product is associated by a sales person intials which is located in Col. C.
I have a userform that contains a listbox of the sales persons intials. When
the user wants to print all the products associated by a particular sales
person, the userform is called, select the sales person, then use autofilter
to hide all other sales people, then print that persons list.
Problem: Say there is a total of 5 Sales People on the worksheet. If the
user only selects 1 Sales Person from the list it prints that persons
filtered product list, but then also prints 4 blank sheets with just the
header, why? My code is only telling it to print the selected list. Any
ideas?
Private Sub btnPrint_Click()
Dim rngFilterRange As Range
Dim i As Integer
Set rngFilterRange = Sheets("Global Schedule").UsedRange
With lboSalesPeople
For i = 0 To .ListCount - 1
If .Selected(i) Then
rngFilterRange.AutoFilter Field:=3, Criteria1:=.List(i),
VisibleDropDown:=False
ActiveSheet.PrintOut Copies:=1, Collate:=True
End If
Next i
End With
rngFilterRange.AutoFilter
End Sub
product is associated by a sales person intials which is located in Col. C.
I have a userform that contains a listbox of the sales persons intials. When
the user wants to print all the products associated by a particular sales
person, the userform is called, select the sales person, then use autofilter
to hide all other sales people, then print that persons list.
Problem: Say there is a total of 5 Sales People on the worksheet. If the
user only selects 1 Sales Person from the list it prints that persons
filtered product list, but then also prints 4 blank sheets with just the
header, why? My code is only telling it to print the selected list. Any
ideas?
Private Sub btnPrint_Click()
Dim rngFilterRange As Range
Dim i As Integer
Set rngFilterRange = Sheets("Global Schedule").UsedRange
With lboSalesPeople
For i = 0 To .ListCount - 1
If .Selected(i) Then
rngFilterRange.AutoFilter Field:=3, Criteria1:=.List(i),
VisibleDropDown:=False
ActiveSheet.PrintOut Copies:=1, Collate:=True
End If
Next i
End With
rngFilterRange.AutoFilter
End Sub