View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
kapiszon kapiszon is offline
external usenet poster
 
Posts: 1
Default VBA to Update Pivot Table

I have a similar issue to your, but still even after reading those posts I
cannot figure out how to sort out my problem.

What I'm trying to do is linking the pivot table filter with a cell that I
placed in a different worksheet. And then, when the value in this cell
changes then in consequence the pivot table changes its filter criteria
automatically. It seems very simple, but I can't resolve it...


Worksheets("Chart_tables").PivotTables("PivotTable 4").PivotFields("Destination") _ = Worksheets("Chart_tables").Range("A1").Value




"Debra Dalgleish" wrote:

Another option is to refer to the pivot table by index number, instead
of name, e.g.:

ActiveSheet.PivotTables(1)

instead of:

ActiveSheet.PivotTables("PivotTable1")

Louise wrote:
Hi,

Can someone help me with my query - I really do not understand why this
doesn't work?!

I have a simple workbook with 2 sheets in in (sheet1 and sheet4).

In sheet1 I have a table of data with 4 fields (Business, PNR, Online,
Tickets).

In sheet4 I have a pivot table running from sheet1 which shows the page
field as business and then a summary of the others below.

I want a list box (validation list) in cell G1 to update the pivot table
page field (business) when I run my macro and I have been using the following
code in a macro:

Sub Alter()
Sheets("Sheet4").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields ("Business Unit
Name").CurrentPage = ActiveSheet.Range("g1").Value
End Sub

...When I run this macro I get the following error and i'm not sure why:

Run-time error '1004':
Unable to get th PivotTables property of the Worksheet class

Any help much appreciated..

Many thanks in advance for your time,




--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html