Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default getPivotData

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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default getPivotData

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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default getPivotData

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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default getPivotData

the #REF suggests that you're trying to read /use a range that doesn't
exist.

"KyWilde" wrote in message
...
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.




  #5   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
GETPIVOTDATA Anne R Excel Discussion (Misc queries) 1 November 13th 09 11:14 PM
GETPIVOTDATA Sunny FL Excel Discussion (Misc queries) 2 October 8th 08 09:02 PM
Getpivotdata David Morris Evans Excel Discussion (Misc queries) 1 November 30th 07 12:18 AM
GETPIVOTDATA Hennie Excel Worksheet Functions 0 June 6th 06 11:47 PM
GETPIVOTDATA Sho Excel Worksheet Functions 1 April 8th 05 06:13 PM


All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"