Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default pivot table with external data

I am querying my database and saving it to a recordset...see below...know how
do i put that into a pivot? I only know how to write the code for an XL based
data source..

Thank you


Sub GetAccessData()
Dim sh As Worksheet

Set sh = Sheets("Sheet2")

Dim MyConnect As String

Dim MyRecordset As ADODB.Recordset

MyConnect = "Provider=Microsoft.ACE.OlEDB.12.0;" & _
"Data Source = C:\Dans_DB.accdb"

Set MyRecordset = New ADODB.Recordset

MyRecordset.Open "DMA", MyConnect, adOpenStatic, adLockReadOnly

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default pivot table with external data

For create your pivot table you can do so:
With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExter nal)
.Connection = "Provider=Microsoft.ACE.OlEDB.12.0;Data Source =
C:\Dans_DB.accdb"
.CommandType = xlCmdSql
.CommandText = your_query
.CreatePivotTable TableDestination:=Range("A3"), _
TableName:=your_pivot_name, DefaultVersion:=xlPivotTableVersion10
End With

After for refresh your data:
ActiveSheet.PivotTables(sNamePivot).PivotCache.Ref resh

Bye, Ste'
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
Pivot Table and External Data Charles Excel Worksheet Functions 0 December 3rd 09 09:33 AM
Pivot Table from External Data? geordie_phil Excel Discussion (Misc queries) 1 June 26th 08 11:13 AM
Pivot table accessing external data Jwaltb Excel Discussion (Misc queries) 6 February 22nd 07 06:04 PM
Setting external data location for a pivot table IMT Excel Programming 1 September 15th 06 01:31 AM
Pivot table using External data nc Excel Discussion (Misc queries) 3 April 26th 05 12:54 PM


All times are GMT +1. The time now is 04:47 PM.

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"