LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Pivottable Field items code -problems

Hi,

I am having a problem with my pivottable code. What I want to do is show all
items for which a certain field is blank. I want it to be able to update and
continue filtering with a single macro. My code sets all items in the field
to be invisible and then makes the (blank) items visible. I came up with the
initial code by recording a macro, but the default macro action individually
sets each tiem. Since the specific items will keep changing (they are dates).
I need to set items to be invisible without knowing beforehand what they are.

So, without further ado, my code:

Private Sub CommandButton1_Click()

Dim x As Integer, itemNum As Long

'creates a pointer to pivottable "unreconciled" or whatever its name will
end up being
Dim URPivot As PivotTable
Set URPivot = ActiveSheet.PivotTables(1)

'Refresh the pivottable
URPivot.PivotCache.Refresh

'reset the field item filter
itemNum = URPivot.PivotFields("Date Invoiced").PivotItems.Count
With URPivot.PivotFields("Date Invoiced")
For x = 0 To itemNum - 1
.PivotItems(x).Visible = False #########exception!!!!##########
Next x
.PivotItems("(blank)").Visible = True
End With

End Sub

So the problem is on the line where I noted the exception, it crashes and I
cant figure out why. Any ideas?
Thanks!


 
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
Using a field name in an IF function for a calculated field in a PivotTable Joel P Excel Worksheet Functions 0 March 29th 07 12:48 AM
PivotTable - How to unhide page field items? Epinn New Users to Excel 3 October 16th 06 01:10 PM
How do I count unique items in a pivottable data field. Jaywestern Excel Discussion (Misc queries) 2 December 29th 05 01:15 AM
Unhide items in PivotTable Dennis Cheung Excel Programming 1 September 20th 05 06:50 AM
PivotTable - PivotTable Field name is not valid - error! miker1999[_17_] Excel Programming 1 June 10th 04 10:30 AM


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