PDA

View Full Version : Problem toggling details



jim.thornton
06-15-2009, 08:49 PM
I'm trying to show the details of a field within a Pivot Table. For some reason, the following code is resulting in Error 1004.

Sub Volume_OpenBreakdown()
'
' Volume_OpenBreakdown Macro
'

'
Range("D7").Select
ActiveSheet.PivotTables("Volume").PivotFields("Agent").ShowDetail = Not ActiveSheet.PivotTables("Volume").PivotFields("Agent").ShowDetail
End Sub


Can anyone here tell me why it isn't working? I'm trying to set it up so that I can add a button and assign this macro to open/close the details. I would rather have one button rather than two (open and close).

Any help is greatly appreciated.

tpoynton
06-16-2009, 09:47 AM
try

ActiveSheet.PivotTables("Volume").PivotFields("Agent").ShowDetail = False

jim.thornton
06-16-2009, 09:57 AM
That works. But I'm trying to set it up so that one button will toggle the boolean variable. If it is currently TRUE, then I want the button to set it to FALSE and if it is currently FALSE then it will set it to TRUE.

tpoynton
06-16-2009, 02:55 PM
untested...

with ActiveSheet.PivotTables("Volume").PivotFields("Agent")
if .ShowDetail = False then
.showdetail = True
else
.showdetail = False
end if
end with

jim.thornton
06-16-2009, 07:51 PM
Unfortunately I'm getting the same error message. Here are two screenshots:

file:///C:/Users/JTHORN%7E1/AppData/Local/Temp/moz-screenshot.jpg