Automatically Printing Autofilters / loop through all filter values then print vba

moomen1999

New Member
Joined
Aug 6, 2020
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
Hello,
I need macro or VBA code to print all data in the table based on # column like filter 1 then print then filter 2 and print etc
can anyone help, please
 

Attachments

  • 1.PNG
    1.PNG
    53.1 KB · Views: 71
  • 2.PNG
    2.PNG
    16.4 KB · Views: 71
  • 3.PNG
    3.PNG
    21.2 KB · Views: 70

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
i try this macro but it didn't work
VBA Code:
Sub Macro1()
'
' Macro1 Macro
'

'
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("#")
        .PivotItems("2").Visible = False
        .PivotItems("3").Visible = False
        .PivotItems("4").Visible = False
        .PivotItems("5").Visible = False
        .PivotItems("6").Visible = False
        .PivotItems("7").Visible = False
        .PivotItems("#N/A").Visible = False
        .PivotItems("(blank)").Visible = False
    End With
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
    Range("A3").Select
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("#")
        .PivotItems("1").Visible = False
        .PivotItems("2").Visible = True
    End With
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
    ActiveSheet.PivotTables("PivotTable1").PivotSelect "'#'[All]", xlLabelOnly, _
        True
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("#")
        .PivotItems("2").Visible = False
        .PivotItems("3").Visible = True
    End With
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
    Range("A3").Select
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("#")
        .PivotItems("3").Visible = False
        .PivotItems("4").Visible = True
    End With
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("#")
        .PivotItems("4").Visible = False
        .PivotItems("5").Visible = True
    End With
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("#")
        .PivotItems("5").Visible = False
        .PivotItems("6").Visible = True
    End With
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("#")
        .PivotItems("6").Visible = False
        .PivotItems("7").Visible = True
    End With
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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