Hi all,
I'm writing a script that prints a specific selection of a pivot table that can be filtered for each day of the week (so Monday, Tuesday, Wednesday etc).
The pivot table has a row called "Dayname" which contains each day of the week. The script uses the range provided in cells J2 and K2.
I've looked around and came up with this script but it is not filtering the pivot table for each day to then print the selection.
Does anyone know how I can best do this?
![]()
Sub PrintSelection() Dim Cval1 As Variant Dim Cval2 As Variant Dim Rng As Range Dim Table As PivotTable Dim All As Range Dim PvI As PivotItem Set All = Worksheets("PIVOT").Range("A1:AZ10000") Set Table = Worksheets("PIVOT").PivotTables("PivotSchedule") For Each PvI In Table.PivotFields("Dayname").PivotItems Cval1 = ActiveSheet.Range("J2").Value Cval2 = ActiveSheet.Range("K2").Value Set Rng = Range(Cval1 & ":" & Cval2, Selection.End(xlDown)) Rng.Select Application.PrintCommunication = True Selection.PrintOut Copies:=1, Collate:=True Next End Sub
Bookmarks