Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default problem with macro for pivot tables

Hi All,

Im trying to write a macro that makes a period visible in
a number of Pivottables (all in one workbook). The period
is mentioned in the cell with the name period.

I have come up with the macro mentioned below, but it does
not work with the 'bPeriodNew' in the following line:
PT.PivotFields("period").PivotItem(bPeriodNew).Vis ible =
True

However, when I change 'bPeriodNew' to, for example, '"2"'
in this line, it works perfectly well.

I checked the value of the line:
bPeriodNew = Range("period").Value
in my direct screen and it gives a correct value. Yet the
macro does not work.

Any idea what I am doing wrong?

Kind regards,
Hans


Sub ChangePeriodPivot

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

bPeriodNew = Range("period").Value
Set sh1 = Worksheets(Array[number of sheets])

For Each wk In Sh1
For Each PT In wk.PivotTables
PT.PivotFields("period").PivotItem(bPeriodNew).Vis ible
= 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
Problem with pivot tables jimbo Excel Worksheet Functions 1 May 27th 11 01:09 PM
Pivot tables problem Amin Excel Discussion (Misc queries) 1 April 26th 10 02:57 PM
Localisation problem with pivot tables Daniel Hilgarth Setting up and Configuration of Excel 2 May 29th 08 07:04 AM
Pivot tables, stupid problem evaluaciondeproyectos08 Excel Discussion (Misc queries) 3 February 8th 07 03:35 PM
Please help: Pivot Tables problem James Yeang Excel Discussion (Misc queries) 5 April 25th 06 01:45 AM


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