Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hey guys,
I would like to ask you why I receive "Debug" question on the following macro? Sub PrintPivTab() Dim i As Integer Dim j As Integer With ActiveSheet.PivotTables("PivotTable1").PivotFields ("TeamMembers") For i = 1 To .PivotItems.Count .PivotItems(i).Visible = True ' = once it arrives until the end of filtering and printing of all the Team ' Members, it blocks here!! (.PivotItems(i).Visible = True) For j = 1 To .PivotItems.Count If j < i Then .PivotItems(j).Visible = False Next j Range("A4").Select Selection.CurrentRegion.Select Selection.PrintOut MsgBox .PivotItems(i).Name & " is now printing" Next i End With End Sub Should I maybe add somewhere that if j = i Then .PivotItems(j).Visible = True? Would this resolve the problem? Thanks so much for your help!! Mark |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If the field is set for automatic sort, you might get that error.
Add code to set the sort to manual, e.g.: With ActiveSheet.PivotTables("PivotTable1").PivotFields ("TeamMembers") .AutoSort xlManual, .Name markx wrote: Hey guys, I would like to ask you why I receive "Debug" question on the following macro? Sub PrintPivTab() Dim i As Integer Dim j As Integer With ActiveSheet.PivotTables("PivotTable1").PivotFields ("TeamMembers") For i = 1 To .PivotItems.Count .PivotItems(i).Visible = True ' = once it arrives until the end of filtering and printing of all the Team ' Members, it blocks here!! (.PivotItems(i).Visible = True) For j = 1 To .PivotItems.Count If j < i Then .PivotItems(j).Visible = False Next j Range("A4").Select Selection.CurrentRegion.Select Selection.PrintOut MsgBox .PivotItems(i).Name & " is now printing" Next i End With End Sub Should I maybe add somewhere that if j = i Then .PivotItems(j).Visible = True? Would this resolve the problem? Thanks so much for your help!! Mark -- Debra Dalgleish Contextures http://www.contextures.com/tiptech.html |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi Debra,
Unfortunately, even if I insert the code you suggested (.AutoSort xlManual, ..Name), the problem remains...So it should be something else then? It's really a pity, because other than this, the code is doing a wonderful job! Rgds, Mark "Debra Dalgleish" wrote in message ... If the field is set for automatic sort, you might get that error. Add code to set the sort to manual, e.g.: With ActiveSheet.PivotTables("PivotTable1").PivotFields ("TeamMembers") .AutoSort xlManual, .Name markx wrote: Hey guys, I would like to ask you why I receive "Debug" question on the following macro? Sub PrintPivTab() Dim i As Integer Dim j As Integer With ActiveSheet.PivotTables("PivotTable1").PivotFields ("TeamMembers") For i = 1 To .PivotItems.Count .PivotItems(i).Visible = True ' = once it arrives until the end of filtering and printing of all the Team ' Members, it blocks here!! (.PivotItems(i).Visible = True) For j = 1 To .PivotItems.Count If j < i Then .PivotItems(j).Visible = False Next j Range("A4").Select Selection.CurrentRegion.Select Selection.PrintOut MsgBox .PivotItems(i).Name & " is now printing" Next i End With End Sub Should I maybe add somewhere that if j = i Then .PivotItems(j).Visible = True? Would this resolve the problem? Thanks so much for your help!! Mark -- Debra Dalgleish Contextures http://www.contextures.com/tiptech.html |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Problem inserting calculated pivot fields into Pivot Table (2007) | Excel Discussion (Misc queries) | |||
How do I replace/select new fields in pivot table using a macro? | Excel Discussion (Misc queries) | |||
fields names do not show in excel 2007 pivot table fields list | New Users to Excel | |||
Pivot Table Macro not inserting all data fields | Excel Discussion (Misc queries) | |||
Filtering or linking Page Fields in an Excel Pivot Table | Excel Programming |