Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Edit PivotTable SQL datasource

Hi, anyone please help....

I have an existing excel file with pivot table referencing to an SQL server
database.

Since the excel file was created by another person no longer in the office,
I do not know exactly what specific sql statement or statements it is linked
to.

Now, the current data contains only items from until a last year. I want to
modify that to include data for the current year, i already modified all sql
statements in the queries folder containing the limited year range, but it
doesnt give any effects in the excel file.

Is there a way to know which sql statement is linked or used as a data
source of an existing excel pivot table? If then, how to I "refresh" the data
in the current excel file to show the modifications i made in the sql
statement? Is the "enable automatic refresh" enough?

Thanks very much for any help...:)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Edit PivotTable SQL datasource

Hi Therezee,

Is there a way to know which sql statement is linked or used as a data
source of an existing excel pivot table? If then, how to I "refresh" the data
in the current excel file to show the modifications i made in the sql
statement? Is the "enable automatic refresh" enough?


You could use this code to show and modify the existing SQL and connection
information:

Sub ChangePivotSource()
Dim sStr As String
sStr = InputBox("Give new SQL command", "Pivot cache",
ActiveWorkbook.PivotCaches(1).CommandText)
If sStr < "" Then
ActiveWorkbook.PivotCaches(1).CommandText = sStr
End If
sStr = InputBox("Give new Connection string", "Pivot cache",
ActiveWorkbook.PivotCaches(1).Connection)
If sStr < "" Then
ActiveWorkbook.PivotCaches(1).Connection = sStr
End If
End Sub

Apart from that, you need to refresh the pivot table manually by selecting a
cell within the PT and choosing Data, refresh.

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Edit PivotTable SQL datasource

hi there!

this is sooo helpful..thanks so much! :)

"Jan Karel Pieterse" wrote:

Hi Therezee,

Is there a way to know which sql statement is linked or used as a data
source of an existing excel pivot table? If then, how to I "refresh" the data
in the current excel file to show the modifications i made in the sql
statement? Is the "enable automatic refresh" enough?


You could use this code to show and modify the existing SQL and connection
information:

Sub ChangePivotSource()
Dim sStr As String
sStr = InputBox("Give new SQL command", "Pivot cache",
ActiveWorkbook.PivotCaches(1).CommandText)
If sStr < "" Then
ActiveWorkbook.PivotCaches(1).CommandText = sStr
End If
sStr = InputBox("Give new Connection string", "Pivot cache",
ActiveWorkbook.PivotCaches(1).Connection)
If sStr < "" Then
ActiveWorkbook.PivotCaches(1).Connection = sStr
End If
End Sub

Apart from that, you need to refresh the pivot table manually by selecting a
cell within the PT and choosing Data, refresh.

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com


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
Disconnecting a Pivottable from its Datasource Chuck Excel Discussion (Misc queries) 0 October 17th 08 05:29 PM
Creating a PivotTable w/o selecting data in an existing PivotTable Damian Excel Discussion (Misc queries) 6 November 2nd 07 04:44 PM
MS Excel 2000 - Change PivotTable DataSource (Access2000 database) Scott Excel Discussion (Misc queries) 0 May 30th 06 03:33 PM
Edit PivotTable by removing Sales Button from ROW area? eholt1941 Charts and Charting in Excel 1 February 14th 06 01:42 AM
Change pivottable datasource zoeloe Excel Discussion (Misc queries) 1 June 21st 05 07:36 PM


All times are GMT +1. The time now is 12:11 AM.

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

About Us

"It's about Microsoft Excel"