hi dave,
yes you are right. it is giving me error when i comment
out "on error resume next" line. This is the message I am
getting "Unable to set the visible property of the pivot
item class" . Is the visible property is read only ?
Roughly what time you will be online so that i can be
online here that time. I am in singapore (GMT + 8:00). Can
I send mails straight to "(e-mail address removed)" ?
Regards
-----Original Message-----
Try just this little portion:
Worksheets("Sheet2").PivotTables("PivotTable1") _
.PivotFields("[Week Date].[Week Date]").PivotItems
("22/09/2003").Visible _
= False
Did that work to hide 22/09/2003?
If it did, then comment out the "on error resume next"
line. Maybe it's masking
a more basic error.
(I'd double check those names to make sure that they're
correct, too.)
Sajith wrote:
hi,
thanks for the help....i have changed my code
accordingly....But "pi.Visible" is always true. I am
not
getting the results.
Tried to update "pi.Visible" = False when even year =
2003 . But it is not updating. Seems like visible
property of pivot items is read only. Always it is true.
When i checked microsoft site, its written visible type
is
read/write boolean. where I am going wrong ?
Or Visible property of Pivot items will not work for
OLAP
data source (my data source is poiting to analysis
Manager) ??
changed code is below...
Dim pf As PivotField
Dim pfmonth As PivotField
Dim pi As PivotItem
Dim Pimonth As PivotItem
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set pf = ActiveSheet.PivotTables("PivotTable1") _
.PivotFields("[Week Date].[Week Date]")
Set pfmonth = ActiveSheet.PivotTables("PivotTable1") _
.PivotFields("[Week Date].[Month]")
Worksheets("Sheet2").PivotTables("PivotTable1") _
.PivotFields("[Week Date].[Week Date]").PivotItems
("22/09/2003").Visible = False
'For Each Pimonth In pfmonth.ChildItems
' If Pimonth.ChildItems = "01/01/2004" Then
' End If
'Next Pimonth
Application.ScreenUpdating = True
Application.DisplayAlerts = True
On Error Resume Next
With pf
.AutoSort xlManual, .SourceName
For Each pi In pf.PivotItems
If IsDate(pi.Caption) Then
If Year(CDate(pi.Caption)) = 2004 Then
pi.Visible = True
Else
pi.Visible = False
End If
End If
Next pi
.AutoSort xlAscending, .SourceName
End With
On Error GoTo 0
Application.DisplayAlerts = True
Application.ScreenUpdating = True
ActiveSheet.PivotTables("PivotTable1").RefreshTable
-----Original Message-----
First, I think I'd just create one more field in my
data
table.
=year() to extract the year from the date.
Then make that Year field a page field.
I could hide/show whatever year I wanted and it would
be
easy to play what-if
games.
But Debra Dalgleish has lots of pivottable code at:
http://www.contextures.com/xlPivot03.html
I stole part of one and came up with this. You'll have
to modify it match your
situation:
Option Explicit
Sub testme()
Dim pf As PivotField
Dim pi As PivotItem
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set pf = Worksheets("sheet2").PivotTables
("PivotTable1") _
.PivotFields("weekdate")
On Error Resume Next
With pf
.AutoSort xlManual, .SourceName
For Each pi In pf.PivotItems
If IsDate(pi.Caption) Then
If Year(CDate(pi.Caption)) = 2004 Then
pi.Visible = False
End If
End If
Next pi
.AutoSort xlAscending, .SourceName
End With
On Error GoTo 0
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Sajith wrote:
hi
let me say thanks first for replying to my query...I
will
try to explain my doubt by making more simpler.
Year is a dimension.
Month & week date is another dimension. Week date is
the
child of Month.
using a macro can i unselect the all the weekdate
whose
year is 2003 ?
below is the current set up
MONTH WEEKDATE AMT
JUNE 01/06/2003 0
06/06/2004 56
11/06/2003 0
11/06/2004 78
JULY 01/07/2003 0
06/07/2004 34
11/07/2003 0
11/07/2004 86
I want to chage like the below...after the macro runs
MONTH WEEKDATE AMT
JUNE 06/02/2004 56
11/02/2004 78
JULY 06/07/2004 34
11/07/2004 86
Thanks in advance for any help regarding this..
Regards
sajith
-----Original Message-----
when you say old data, does it mean that the data
that
is
showing up in
the pivot table does not exist in the database on
which
this pivot
table is based upon? if so, then you can delete such
items. go over to
http://www.contextures.com/xlPivot04.html.
if you mean something else, then perhaps i did not
understand you
question right. provide a little more detail. do you
mean
that you dont
want items showing up that have amount as '0'.
--
icestationzbra
------------------------------------------------- ---
---
---
--------------
icestationzbra's Profile:
http://www.excelforum.com/member.php?
action=getinfo&userid=4580
View this thread:
http://www.excelforum.com/showthread.php?
threadid=261540
.
--
Dave Peterson
(e-mail address removed)
.
--
Dave Peterson
(e-mail address removed)
.