LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Display only selected fields in a PivotTable with VBA

Hi all,

I would like to display dates in a pivottable that match with dates on a list.


I am one step away, but not sure where I made a mistake


'count number of dates in a pivot talbe
intCountRows1 = ActiveSheet.PivotTables("PivotTable3").PivotFields ("Date").
PivotItems.Count

'count number of dates in a list
intCountRows2 = Application.WorksheetFunction.CountA(Sheet1.Range( "G:G"))

'tick all dates to be displayed
For i = 1 To intCountRows1
With ActiveSheet.PivotTables("PivotTable3").PivotFields ("Date")
.PivotItems(i).Visible = True
End With
Next

'compare a list against the dates in a pivottable and display only those that
match.
a = 2

Do While a <= intCountRows2

For i = 1 To intCountRows1

strField = Sheet1.Cells(a, 7).Value

With ActiveSheet.PivotTables("PivotTable3").PivotFields ("Date")

If .PivotItems(i).Value = strField Then
.PivotItems(i).Visible = True
a = a + 1
Else
.PivotItems(i).Visible = False
End If

End With
Next

Loop

End Sub

Thanks very much for your help in advance

Best regards

Slav

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200605/1
 
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
2003 PIvotTable Calculated Fields Kay Excel Discussion (Misc queries) 3 April 24th 10 06:41 PM
Pivottable Sum of fields. Saviz Excel Discussion (Misc queries) 1 July 17th 08 12:10 PM
pivottable calculated fields HelpAl Excel Discussion (Misc queries) 3 December 8th 05 10:18 PM
PivotTable-Fields Page Andrea Excel Programming 1 December 15th 04 02:08 PM
pivottable page fields Grant Excel Programming 1 October 16th 04 09:09 PM


All times are GMT +1. The time now is 06:36 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"