ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with Pivot Items (https://www.excelbanter.com/excel-programming/374667-problem-pivot-items.html)

Manish Jaitly[_2_]

Problem with Pivot Items
 
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

Charles Chickering

Problem with Pivot Items
 
Manish, Please post your code and I would be happy to help.
--
Charles Chickering

"A good example is twice the value of good advice."


"Manish Jaitly" wrote:

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


Manish Jaitly[_2_]

Problem with Pivot Items
 
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.





"Charles Chickering" wrote:

Manish, Please post your code and I would be happy to help.
--
Charles Chickering

"A good example is twice the value of good advice."


"Manish Jaitly" wrote:

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


Charles Chickering

Problem with Pivot Items
 
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
--
Charles Chickering

"A good example is twice the value of good advice."


"Manish Jaitly" wrote:

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.





"Charles Chickering" wrote:

Manish, Please post your code and I would be happy to help.
--
Charles Chickering

"A good example is twice the value of good advice."


"Manish Jaitly" wrote:

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



All times are GMT +1. The time now is 02:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com