Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Inserting getpivotdata formula using vba macro

Hi,

I try to insert the following GETPIVOTDATA formula

Range("H7").Formula = "=GETPIVOTDATA(" _
& Chr(34) & "Hours" & Chr(34) & ";'complete pivot'!$A$1;" _
& Chr(34) & "OpAc" & Chr(34) & ";" & Chr(34) & "0190" & Chr(34) & ";" _
& Chr(34) & "Rec. Order" & Chr(34) & ";" & Chr(34) & "4711" & Chr(34) &
";" _
& Chr(34) & "Employee/app.name" & Chr(34) & ";" & Chr(34) & "John Doe" &
Chr(34) & ";" _
& Chr(34) & "Network" & Chr(34) & ";" & Chr(34) & "123" & Chr(34) & ";" _
& Chr(34) & "CW" & Chr(34) & ";" & "31" & ")"

If I leave out the leading equal sign before GETPIVOTDATA, the string is
correctly inserted. I only need to manually add the = in each cell and the
correct value is displayed.

If I try to run the above code including the leading = sign I get Runtime
"Error 1004 - Application defined or object defined error"

I know I can use GetPivotData directly in my macro, but I want to run the
macro just once and have Excel update the table automatically instead of
having to run the macro each time the underlying data base changes.

Any help on this would by greatly appreciated.

Cheers,
Alex
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Inserting getpivotdata formula using vba macro

VBA likes to use the comma separator in formulas--no matter what your list
separator is.



AlexF wrote:

Hi,

I try to insert the following GETPIVOTDATA formula

Range("H7").Formula = "=GETPIVOTDATA(" _
& Chr(34) & "Hours" & Chr(34) & ";'complete pivot'!$A$1;" _
& Chr(34) & "OpAc" & Chr(34) & ";" & Chr(34) & "0190" & Chr(34) & ";" _
& Chr(34) & "Rec. Order" & Chr(34) & ";" & Chr(34) & "4711" & Chr(34) &
";" _
& Chr(34) & "Employee/app.name" & Chr(34) & ";" & Chr(34) & "John Doe" &
Chr(34) & ";" _
& Chr(34) & "Network" & Chr(34) & ";" & Chr(34) & "123" & Chr(34) & ";" _
& Chr(34) & "CW" & Chr(34) & ";" & "31" & ")"

If I leave out the leading equal sign before GETPIVOTDATA, the string is
correctly inserted. I only need to manually add the = in each cell and the
correct value is displayed.

If I try to run the above code including the leading = sign I get Runtime
"Error 1004 - Application defined or object defined error"

I know I can use GetPivotData directly in my macro, but I want to run the
macro just once and have Excel update the table automatically instead of
having to run the macro each time the underlying data base changes.

Any help on this would by greatly appreciated.

Cheers,
Alex


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Inserting getpivotdata formula using vba macro

Thank you so much. One of these things you just have to know, I suppose...

"Dave Peterson" wrote:

VBA likes to use the comma separator in formulas--no matter what your list
separator is.



AlexF wrote:

Hi,

I try to insert the following GETPIVOTDATA formula

Range("H7").Formula = "=GETPIVOTDATA(" _
& Chr(34) & "Hours" & Chr(34) & ";'complete pivot'!$A$1;" _
& Chr(34) & "OpAc" & Chr(34) & ";" & Chr(34) & "0190" & Chr(34) & ";" _
& Chr(34) & "Rec. Order" & Chr(34) & ";" & Chr(34) & "4711" & Chr(34) &
";" _
& Chr(34) & "Employee/app.name" & Chr(34) & ";" & Chr(34) & "John Doe" &
Chr(34) & ";" _
& Chr(34) & "Network" & Chr(34) & ";" & Chr(34) & "123" & Chr(34) & ";" _
& Chr(34) & "CW" & Chr(34) & ";" & "31" & ")"

If I leave out the leading equal sign before GETPIVOTDATA, the string is
correctly inserted. I only need to manually add the = in each cell and the
correct value is displayed.

If I try to run the above code including the leading = sign I get Runtime
"Error 1004 - Application defined or object defined error"

I know I can use GetPivotData directly in my macro, but I want to run the
macro just once and have Excel update the table automatically instead of
having to run the macro each time the underlying data base changes.

Any help on this would by greatly appreciated.

Cheers,
Alex


--

Dave Peterson

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
Macro Inserting a formula Kristi Excel Discussion (Misc queries) 0 May 13th 09 05:29 PM
Need help inserting formula with macro Judy Ward Excel Programming 5 August 12th 08 03:30 AM
Average from the GETPIVOTDATA formula Rob Excel Discussion (Misc queries) 1 May 15th 07 10:19 AM
Help a Newbie! Using GETPIVOTDATA formula! certain_death Excel Discussion (Misc queries) 1 August 9th 06 04:54 PM
GETPIVOTDATA FORMULA nazzoli Excel Worksheet Functions 0 November 22nd 05 09:41 PM


All times are GMT +1. The time now is 07:20 PM.

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"