How to update Getpivottable formula in Excel throught VBA

raghavcacs

Board Regular
Joined
Mar 13, 2009
Messages
84
Hi!

When I am trying to update the below formula in excel cell through VBA, it is throwing out an error

Range("B" & c).Text = "=(GETPIVOTDATA(" & " Actuals" & ",$A$6))/2"

but in the range given , the above formula is pasted without quotes for the word Actuals in excel which needs to be there as per the syntax of Getpivot table.

Can anybody help me how can i do it in Excel VBA?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Where is the error occurring?

On the worksheet or in the code?
 
Upvote 0
#name? error occurs in worksheet because in the sheet I am seeing a formula like the below:
=GETPIVOTDATA(Actuals,$A$6))/2

but it should be =
=GETPIVOTDATA("Actuals",$A$6))/2

Quotes before and after the word actuals can not be given in VBA.


<TABLE style="WIDTH: 131pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=174 border=0 x:str><COLGROUP><COL style="WIDTH: 131pt; mso-width-source: userset; mso-width-alt: 3181" width=174><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; WIDTH: 131pt; BORDER-BOTTOM: #d4d0c8; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" width=174 height=17 x:err="#NAME?">

</TD></TR></TBODY></TABLE>
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,652
Members
448,975
Latest member
sweeberry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top