Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default 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
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
Changing a field setting in a pivot table The Rook[_2_] Excel Discussion (Misc queries) 3 September 5th 08 05:29 PM
Pivot Table field macro [email protected] Excel Worksheet Functions 1 June 22nd 08 12:21 AM
Changing field names without affecting pivot table csdjj Excel Discussion (Misc queries) 2 April 15th 08 05:16 PM
Workbook Open macro/& Pivot Table Calculated field query Frank Kabel Excel Programming 0 May 4th 04 03:55 PM
Dynamically changing a calculated field in Pivot Table Rick[_19_] Excel Programming 4 November 7th 03 04:46 AM


All times are GMT +1. The time now is 04:03 PM.

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

About Us

"It's about Microsoft Excel"