Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing field in Pivot Table with macro
I have a problem with the macro below that makes the new
period (mentioned in my sheet OVERVIEW, cell E7) visible in a number of Pivot Tables. For some reason, the value of 'Worksheets("OVERVIEW").Range ("E7").Value' is not assigned to i. When I query the 'i = Worksheets("OVERVIEW").Range("E7").Value' statement in the immediate window, i get False as answer. However, when I only query 'Worksheets("OVERVIEW").Range("E7").Value' I get 2, the correct value of our current period. Any idea what I am doing wrong? regards, Hans Sub PivotChangePeriod() Dim i As Long Dim PT As PivotTable Dim PI As PivotItem Dim Sh1 As Sheets Dim wk As Worksheet i = Worksheets("OVERVIEW").Range("E7").Value Set Sh1 = Worksheets(Array("ALEN", "ALEN (2)")) For Each wk In Sh1 For Each PT In wk.PivotTables PT.PivotFields("period").PivotItem(i).Visible = True Next PT Next wk End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Changing a field setting in a pivot table | Excel Discussion (Misc queries) | |||
Pivot Table field macro | Excel Worksheet Functions | |||
Changing field names without affecting pivot table | Excel Discussion (Misc queries) | |||
Workbook Open macro/& Pivot Table Calculated field query | Excel Programming | |||
Dynamically changing a calculated field in Pivot Table | Excel Programming |