Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 19th, 2012, 04:23 AM
Authorized User
 
Join Date: Dec 2009
Posts: 69
Thanks: 6
Thanked 0 Times in 0 Posts
Default VBA and Pivot Table

Hi,

I have a pivot table that contains several regions and each region has its own worksheet. The Pivot table is sitting in one worksheet and I would like to move it to any worksheet that I want when activating it. Every time I do this, I get the following run time error 1004:

"Unable to get the PivotTables property of the worksheet class".
Can anyone please explain how to get rid of this silly message.

Code:
My code is:
 
Sub PivotMove()
 If Worksheets("All") Is ActiveSheet Then
 ActiveSheet.PivotTables("PivotTable1").Location = "All!$I$65"
 With ActiveSheet.PivotTables("PivotTable1").PivotFields("Region")
 .PivotItems("All").Visible = True
 End With
 
End Sub
Any help would be appreciated.

Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Pivot table VBA jae113 Excel VBA 2 November 18th, 2011 02:13 PM
Filter Pivot Table(s) based on Cell Value outside Pivot steplawn Beginning VB 6 0 May 11th, 2010 09:01 PM
How to replace pivot table data fields using VBA? rstober Excel VBA 2 August 19th, 2005 06:06 AM
Help Needed to write vba for Pivot Table in Excel sunny76 Excel VBA 1 June 28th, 2005 01:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.