ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Refreshing Pivot tables link to a SQL Server (https://www.excelbanter.com/excel-programming/354920-refreshing-pivot-tables-link-sql-server.html)

dins45768

Refreshing Pivot tables link to a SQL Server
 
I have 2 pivot tables in an EXCEL workbook that are linked to tables located
on a SQL Server. The end user will be responsible for refreshing these tables
by clicking a button. Right now a dialog box appears and requires the user to
enter an id and password for each table. I want to have the pivot tables
refresh on open without prompting for a password. Is this possible.

I have started to write the following code but I don't know if I am on the
right track.

Sub Refresh_Data()
'Set up the connection string, reference an ODBC connection
connstring = _
"ODBC;DSN=Gulf States SQL Server;UID=e45768;PWD=e45768;Database=DataMart"
'Refresh Pivot Tables
Worksheets("PvtTbls").PivotTables("PivotTable1").P ivotCache.Refresh
Worksheets("PvtTbls").PivotTables("PivotTable2").P ivotCache.Refresh

End Sub

I am a programming novice and not sure how to make this work. Any help would
be greatly appreciated.


All times are GMT +1. The time now is 10:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com