Problem with Pivot Items

G

Guest

Hi

I am facing a problem. I am getting the error 1004 "Unable to get data range
property of the pivot item class". My pivot has 3 column fields (or rather
pivot
items) They are - First Box, Second Box, Third Box. First Box and Second Box.
When the loop runs through First and Second Box, the program runs smoothly
because they both contain data and are visible in the pivot. However when the
loop gets to the Third Box which has no data and is not visible (it is
clicked
on the field drop down though) , I get the above error. This appears to be
self
deating as I am unable to understand what code to write that filters or
ignores
the Third Box so that I do not get this run time error.

Please help as I am unable to proceed because of this.

Thanks
Manish
 
G

Guest

Thanks. Here is the code

For Each pvtitem In pvttable.PivotFields(x)).PivotItems

If (pvtitem.Name = "First Box" Or pvtitem.Name = "Second Box" Or
pvtitem.Name = "Third Box" Then

For Each c In pvtitem.DataRange ' error strikes here when the
program hits the Third Box which has no data and is not visible on the pivot.
In the drop box it is ticked. Actaully for a particualar page vale there is
no Third Box and I get this data. For other page values Third Box has values
so is visible and error does not occur.
 
G

Guest

Manish, Try using error detecting:
On Error Resume Next
For Each c In pvtitem
If c Is Nothing Then Exit For
'Rest of Code
Next
On Error Goto 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top