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: 25
Default Macro to make period visible in pivot table

I have created the macro below to make the current month
(bPeriodNew) visible in a number of Pivot Tables (some 15
in total). However, it doesnt work in some of them and in
most cases I don't know why. In one or two the pivot table
would overlap another one with the new period added and in
these cases I can understand why the macro doesn't run.
But in other Pivot tables everything seems to be OK and
yet the period is not make visible.

The Pivot Tables I use are all linked to external
databases.

Any ideas what might be wrong? Or any suggestions for
another (better) macro?


Regards
Hans

Sub AddPivotPeriod

Dim bPeriodNew As Byte
Dim PT As PivotTable
Dim PI As PivotItem
Dim Sh1 As Sheets
Dim wk As Worksheet

bPeriodNew = Range("period").Value
Set Sh1 = Worksheets(Array("data"))

For Each wk In Sh1
For Each PT In wk.PivotTables
For Each PI In PT.PivotFields"period").PivotItems
On Error Resume Next
If PI.Name = bPeriodNew Then
PI.Visible = True
End If
Next PI
Next PT
Next wk

End Sub

 
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
Pivot Table - Finanical information by Period as a month DRW Excel Discussion (Misc queries) 1 November 17th 09 05:50 AM
How to make pivot table based on two more sheets Edward Wang Excel Discussion (Misc queries) 0 March 26th 09 08:13 PM
How can I make pivot table sub-totals bold? Neville Bailey Excel Discussion (Misc queries) 5 May 14th 08 07:00 PM
How do I make a cashflow with pivot table? Luana - Brazil Excel Worksheet Functions 1 September 27th 07 09:38 AM
How do you set up a Pivot table. Ccan't make it work Pivot Poor Charts and Charting in Excel 1 August 24th 06 02:15 AM


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