Advertisement

02.26.2008 at 03:29PM PST, ID: 23195484
[x]
Attachment Details

change sourcedata SQL of pivot table using Excel VBA

Asked by MKarris in Microsoft Excel Spreadsheet Software

Tags: Microsoft, Excel, 2003

I have 34 pivot tables sharing 6 pivot caches.  
Each pivot cache is linked to SQL server query and I update each of the 6 caches by changing the date in MSQuery SQL line.  For example, here is how one cache is updated:

exec qryWtd_Index_Ratios_for_Date '11/30/2007'

My question: how can I use VBA to either update each of the 34 pivot tables or each of the 6 caches whenever I change the date?  I do not want to make a new pivot each time.  I want to re-use the existing pivots.

When I record what I want to do I get this but it does not solve my problem:
    ActiveSheet.PivotTableWizard SourceType:=xlExternal, SourceData:=Array( _
        "exec qryWtd_Index_Ratios_for_Date '11/30/2007'"), Connection:=Array(Array( _
        "ODBC;DRIVER=SQL Server;SERVER=invest2;UID=michael;APP=Microsoft Office 2003;WSID=MICHAEL;DATABASE=Equity Beta Application;Trust" _
        ), Array("ed_Connection=Yes"))

Thanks!Start Free Trial
[+][-]02.27.2008 at 03:37AM PST, ID: 20993112

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.27.2008 at 08:54AM PST, ID: 20995655

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.27.2008 at 09:07AM PST, ID: 20995810

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.28.2008 at 06:03AM PST, ID: 21003718

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Excel Spreadsheet Software
Tags: Microsoft, Excel, 2003
Sign Up Now!
Solution Provided By: rorya
Participating Experts: 1
Solution Grade: A
 
 
[+][-]02.28.2008 at 09:08AM PST, ID: 21005843

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.28.2008 at 09:17AM PST, ID: 21005948

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.28.2008 at 11:27AM PST, ID: 21007173

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.03.2008 at 12:01PM PST, ID: 21035064

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628