• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

"Unable to get the data range property of the pivotitem class" error

WOlfPack

New Member
Hello VBA gurus. I am getting the "Unable to get the data range property of the pivotitem class" error while running my macro. In a nutshell, I am trying to achieve the following: Select a data range from a pivot table based on two column labels (there are three pivot items for label-1 and two items for label-2; therefore a total of 3x2=6 potential data ranges. User selects the two pivot items, one for each label), copy the range, and paste it on another sheet. Everything goes well as long as there is data for the Label1-label2 permutation. Actually, the error handler that I've put in place also takes care of the first case when there is no data range. However, I get the error message when it comes to the "second" point where there is no data range. Attached is the part of my macro that hope will shed light on my question. Thank you in advance for any guidance you can provide on this.
 

Attachments

  • Error.JPG
    Error.JPG
    126.3 KB · Views: 20
Try something like this...

Code:
If IsEmpty(r) Or Intersect(r, [my]) Is Nothing Then Exit Sub
 
Back
Top