Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Macro on filtering pivot table (pivot fields) = debug

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Macro on filtering pivot table (pivot fields) = debug

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Macro on filtering pivot table (pivot fields) = debug

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem inserting calculated pivot fields into Pivot Table (2007) wamiller36 Excel Discussion (Misc queries) 1 March 5th 10 11:40 PM
How do I replace/select new fields in pivot table using a macro? snowdog Excel Discussion (Misc queries) 1 August 4th 09 03:58 AM
fields names do not show in excel 2007 pivot table fields list marlo17 New Users to Excel 2 December 1st 08 01:25 PM
Pivot Table Macro not inserting all data fields [email protected] Excel Discussion (Misc queries) 0 October 27th 06 04:55 AM
Filtering or linking Page Fields in an Excel Pivot Table Nick Weekes Excel Programming 0 April 27th 04 02:20 PM


All times are GMT +1. The time now is 11:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"