Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Showing/Hiding Pivot-Items

I have the following script:
For i = 1 To ActiveWorkbook.Sheets().Count
Sheets(i).Select
For j = 1 To ActiveSheet.PivotTables().Count
ActiveSheet.PivotTables(j).PivotSelect "", xlOrigin
ActiveSheet.PivotTables(j).RefreshTable

ActiveSheet.PivotTables(j).PivotFields("Year").Cur rentPage =
CurrYear
With ActiveSheet.PivotTables(j).PivotFields("YearMonth" )
For k = 1 To .PivotItems.Count
If Val(.PivotItems(k)) <= Currmonth Then
If .PivotItems(k).Visible = False Then
.PivotItems(k).Visible = True
End If
Else
If .PivotItems(k).Visible = True Then
.PivotItems(k).Visible = False
End If
End If
Next 'k
End With
Range("A1").Select
Next 'j
Next 'i


I sometimes receive the error
RuntimeError: 1004
Unable to set the visibility Property of the PivotItems Class.

What can be the cause, how can it be solved?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Showing/Hiding Pivot-Items

You can not hide all of the items... That could be the problem...
--
HTH...

Jim Thomlinson


"amac" wrote:

I have the following script:
For i = 1 To ActiveWorkbook.Sheets().Count
Sheets(i).Select
For j = 1 To ActiveSheet.PivotTables().Count
ActiveSheet.PivotTables(j).PivotSelect "", xlOrigin
ActiveSheet.PivotTables(j).RefreshTable

ActiveSheet.PivotTables(j).PivotFields("Year").Cur rentPage =
CurrYear
With ActiveSheet.PivotTables(j).PivotFields("YearMonth" )
For k = 1 To .PivotItems.Count
If Val(.PivotItems(k)) <= Currmonth Then
If .PivotItems(k).Visible = False Then
.PivotItems(k).Visible = True
End If
Else
If .PivotItems(k).Visible = True Then
.PivotItems(k).Visible = False
End If
End If
Next 'k
End With
Range("A1").Select
Next 'j
Next 'i


I sometimes receive the error
RuntimeError: 1004
Unable to set the visibility Property of the PivotItems Class.

What can be the cause, how can it be solved?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Showing/Hiding Pivot-Items

If the field is set to Automatic sort, you may have problems. If that's
the case, to prevent the error, set the Sort for the field to Manual.
For example:

Dim intASO As Integer
With ActiveSheet.PivotTables("PivotTable2").PivotFields ("Employee")
intASO = .AutoSortOrder
.AutoSort xlManual, .SourceName
.PivotItems("1").Visible = False
.PivotItems("42").Visible = True
.AutoSort intASO, .SourceName
End With



amac wrote:
I have the following script:
For i = 1 To ActiveWorkbook.Sheets().Count
Sheets(i).Select
For j = 1 To ActiveSheet.PivotTables().Count
ActiveSheet.PivotTables(j).PivotSelect "", xlOrigin
ActiveSheet.PivotTables(j).RefreshTable

ActiveSheet.PivotTables(j).PivotFields("Year").Cur rentPage =
CurrYear
With ActiveSheet.PivotTables(j).PivotFields("YearMonth" )
For k = 1 To .PivotItems.Count
If Val(.PivotItems(k)) <= Currmonth Then
If .PivotItems(k).Visible = False Then
.PivotItems(k).Visible = True
End If
Else
If .PivotItems(k).Visible = True Then
.PivotItems(k).Visible = False
End If
End If
Next 'k
End With
Range("A1").Select
Next 'j
Next 'i


I sometimes receive the error
RuntimeError: 1004
Unable to set the visibility Property of the PivotItems Class.

What can be the cause, how can it be solved?



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

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
userforms showing and hiding Laurin[_11_] Excel Programming 4 December 20th 05 06:07 PM
hiding and showing graphs chrisrowe_cr Excel Worksheet Functions 0 September 2nd 05 11:22 AM
showing hidden items of a pivot table in a cell macca666 Excel Programming 0 July 23rd 05 10:02 AM
Showing and hiding columns BatMan Excel Programming 1 July 21st 04 06:11 PM
hiding showing columns using checkboxes ronda Excel Programming 1 June 8th 04 01:27 AM


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

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"