View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Héctor Miguel Héctor Miguel is offline
external usenet poster
 
Posts: 434
Default Create a pivottable from a recordset?

hi, !

I am trying to create a pivot table from a dynamic query
- so I create the query in VBA and then want to create a pivot table with that query.
What I am trying to do is to first create the pivotcache.
I am pretty lost on this one
- I can create a cache with Excel data, but am having a hard time creating it from a recordset.
Any ideas?


- set and open your connection-object
- set your recordset-object
- build the query-string
- open the recordset-object with your connection and query-string
- set / add your pivot-cache (sourcetype should be external)
- set your pivot-cache recordset as your opened recordset-object
- set your pivot-table (pivot-cache and destination)
- add (according your needs) the pivot-fields (rowfields, pagefields, pivotfields, ...)
- arrange the orientation (datafields, columnfields, ...), position, function, number format, etc..
- close your objects (recordset and connection)
- it's done !

hard to provide an "useful" example wothout your "real source data/needs/query/..." -???-

hth,
hector.