Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Error 1004 with PivotItems.Visible

I record this macro as I un-select one item and then select another item:
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Env")
.PivotItems("1").Visible = False
.PivotItems("42").Visible = True
End With
But when I then try to run (playback) the macro, I get an error 1004.
I still get the error if I change the order and put True first, then False.

What am I missing?

Thanks,
Charlie Rowe


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Error 1004 with PivotItems.Visible

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

Charlie Rowe wrote:
I record this macro as I un-select one item and then select another item:
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Env")
.PivotItems("1").Visible = False
.PivotItems("42").Visible = True
End With
But when I then try to run (playback) the macro, I get an error 1004.
I still get the error if I change the order and put True first, then False.

What am I missing?

Thanks,
Charlie Rowe




--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Error 1004 with PivotItems.Visible

Debra,

WOW, thank you so much; I would have never figured that out.
How did you ever figure it out?

Charlie Rowe



"Debra Dalgleish" wrote:

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

Charlie Rowe wrote:
I record this macro as I un-select one item and then select another item:
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Env")
.PivotItems("1").Visible = False
.PivotItems("42").Visible = True
End With
But when I then try to run (playback) the macro, I get an error 1004.
I still get the error if I change the order and put True first, then False.

What am I missing?

Thanks,
Charlie Rowe




--
Debra Dalgleish
Excel FAQ, Tips & Book List
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
Controlling Pivotitems.visible sxhwabbiemike Excel Discussion (Misc queries) 0 January 21st 09 03:09 AM
Runtime error 1004 - unable to set Visible property of Worksheet c SueJB Excel Programming 2 October 4th 05 02:27 PM
Visible PivotItems matching criteria westg Excel Programming 1 August 31st 05 05:34 PM
Always keep the same 4 PivotItems visible Martin[_21_] Excel Programming 2 April 27th 05 10:17 AM
Run-time error '1004' - Unable to set the Visible property of the Worksheet class Shalin Chopra Excel Programming 3 November 25th 03 08:38 PM


All times are GMT +1. The time now is 09:52 AM.

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"