Thread: getPivotData
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Debra Dalgleish Debra Dalgleish is offline
external usenet poster
 
Posts: 2,979
Default getPivotData

Try converting the date to a long integer:

"=GETPIVOTDATA(""Sum of xfers"",Pivot_table!R3C1,""day""," &
CLng(temp3) & ")"


KyWilde wrote:
Thanks Patrick... unfortunately when I use the recommended code I get the
same #REF error. This is really confusing me. Any more suggestions?
Thanks!

"Patrick Molloy" wrote:


you're hard-coding the word temp3 instead of using it as a variable

const FORMULA as String = _
"=GETPIVOTDATA(""Sum of xfers"",Pivot_table!R3C1,""day"",TEMP3)"
dim sFormula as String
sFormula = Replace( FORMULA,"TEMP3",temp3)
ActiveCell.FormulaR1C1 = sFormula


you could simply concatenate it, but the code above is real easy to see and
understand and debug.

ActiveCell.FormulaR1C1 = _
"=GETPIVOTDATA(""Sum of xfers"",Pivot_table!R3C1,""day""," & temp3 & ")"





"KyWilde" wrote:


I am trying to use a variable in the GetPivotData function and I keep getting
#REF error. Here is my syntax:
Cells(lRow, 5).Select
ActiveCell.FormulaR1C1 = _
"=GETPIVOTDATA(""Sum of
xfers"",Pivot_table!R3C1,""day"",DATE(2005,3,29 )"

When I try:
Cells(lRow, 5).Select
ActiveCell.FormulaR1C1 = _
"=GETPIVOTDATA(""Sum of xfers"",Pivot_table!R3C1,""day"",temp3)"

using temp3, a variable holding a date, it gives me a #REF error. Can I not
use variables here? What can I do to make this dynamic?

Thanks.





--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html