Consulting

Results 1 to 3 of 3

Thread: get value of cell for pivot table

  1. #1
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location

    get value of cell for pivot table

    I know I can't use a named cell in a pivot table calculated field.

    But how do I get a macro to refresh a pivot table, and while it's at it, update the calculated field called "target" usiing the value in a cell named TG?

    So where the code says:
    [vba]ActiveSheet.PivotTables("PivotTable3").CalculatedFields("Target"). _
    StandardFormula = "=12.17%"[/vba]

    I want the code to change the 12.17% to whatever value is in the cell named TG.

    Thanks
    Last edited by Sir Babydum GBE; 04-25-2008 at 05:02 AM.
    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

  2. #2
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    Something like:
    [VBA]
    With ActiveSheet.PivotTables("PivotTable3")
    .CalculatedFields("Target").StandardFormula = "=" & Range("TG").Value
    .RefreshTable
    End With
    [/VBA]
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location
    Quote Originally Posted by rory
    Something like:
    [vba]
    With ActiveSheet.PivotTables("PivotTable3")
    .CalculatedFields("Target").StandardFormula = "=" & Range("TG").Value
    .RefreshTable
    End With
    [/vba]
    Thanks Rory - fab!
    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •