Automatic GETPIVOTDATA formula generation from within VBA?

J

John Brock

If I have a pivot table and I want a formula outside of the table
to refer to one of the table values, I just type "=" and click on
the pivot cell, and Excel automatically generates the appropriate
GETPIVOTDATA(...) formula. This is very convenient (and I know
how to turn the feature off if necessary).

But what if I want to do the same thing from within VBA? Recording
a macro I see something like:

ActiveCell.FormulaR1C1 = "=GETPIVOTDATA(""Data_Field"",R13C26,""Field_1"",""Value_1"",...)"

Conceptually this is easy, but in practice constructing all the
formula strings I'm going to need is going to be a pain. Is there
any way I can ask Excel to construct a GETPIVOTDATA formula
automatically by specifying the cell, the way it works when I do
it by hand?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top