index > Visual Basic for Applications (VBA) > How to copy pivot table RESULT from Access to Excel

How to copy pivot table RESULT from Access to Excel


I need to produce a highly formated pivot table report in Access and can only achieve so much. However, if I could programatically select the pivot table (equivalent of keys [Ctrl]+Angel) then copy and paste into Excel, I can use VBA to format the report in Excel.

My problem is that I cannot find a way to programatically select the pivot table in Access. I have tried Sendkeys "^A" as a last resort but this doesn't work. Exporting to Excel doesn't work either as it exports the pivot table, not the result.

Rick 3021

Hi Rick,

Suggest that you try send the recordset (if it is small enough) to an Excel spreadsheet with can contain your pivot table .

I have an App which is too large for this so I work through the recordset and use VBA to write the data into the appropriate cells of my report spreadsheet. Both methods work OK




ADG
ADG

Thanks for your interest however the pivot table in Access can do things which I don't think Exel can. In particular, I do not want to perform any kind of summary analysis on the data e.g. Sum, Count etc. The Access Pivot table can show 'detail' e.g. text as well as summarised 'data'. It is the detail I want and can produce in Access, however I also want contitional formating and a few other things which pivot table forms can't do.

I therefore thought I would copy and paste the Access pivot table to Excel where I can complete the formatting using VBA but I am really stuck for a way to automate "Select All" i.e. pressing the "Control" key and the "A" key together.

Every other way I have tried e.g. exporting to Excel opens an Excel Pivot table. This applies the Count function to the text details I am reporting which is not what I want.

Rick 3021

Hi Rick,

Have you had any luck resolving this problem?

I am also trying to copy the results from a pivot table control and paste the results into Excel.

KD

KD11
I'm having a similar problem with a large dataset. I can export smaller result sets, but the query I'm using has over 150,000 rows: too many for Excel. However, the actual pivot table result only contains 4,500 rows

I tried Export - didn't work, too many rows. Tried Copy & Paste, got an "Out of Memory" error




--John Hunter
jshunter

Try this.

"str_spreadsheet_name" holds the name of a file that has already been exported and Excel is open and running.

"obj_xls" then picks up the open spreadsheet.

It then creates pivot table called "Holdings" in the Excel sheet at AQ1, with rows being "rec_id", columns being "fund_name" and pivot field being "sum of fund_value".

It then copies the pivot table and does a patsespecial - values only. This removes all of the pivot table formatting.

It then tidies up the headings etc. If you run the process in debug you'll be able to see it working line by line.

Hope this is of use.

KD

Private Function reformat_fund_totals()

KD11
reply 6

You can use google to search for other answers

 

More Articles

• How can filter object ?
• Copying email contents into Excel Spreadsheet via an Excel Macro
• Superscripting in PowerPoint
• Linking Infopath Toolbar Buttons to VBScripts embedded in Templat...
• Bounded frame object... how to activate in native app.
• How Can I Register The Yahoo DomainKey For My Mail Server ?
• Excel, fullscreen, taskbar
• Excel macro to send email not running
• Migrating from VC++ 6.0 to VC++ 7.1
• Accessing Visual FoxPro data using VBA (Excel)
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

• Accessing control textbox text
• VBA Mail Merge Question
• OWC10 Chart to print on a report
• List Box Search
• Excel DDE Server
• Multithreading, Callback & VBA in Po
• API Used in VBA
• Parsing text with tags in Excel using VBA
• AutoResize Merged Cells
• MS Word Option Button Collection
• [off topic] Windows Live Messenger Probl
• how to read merged cells?
• Date and time picker control
• Using internal IP Address (Printers) in
• Copying email contents into Excel Spread

Hot Articles

• Is VBA SDK free and ...?
• Setting Autonumber back to zero
• Copy Outlook email into Excel
• custom toolbar error
• office2003 chart object(Spreadsheet1, Ch
• Copy and Paste Values
• How do you find out the Windows User Nam
• VB Postgres connection problem
• Refreshing a web query that is behind a
• Autosave using VBA after n minutes
• How to capture Windows Menu Key in Excel
• SaveAs help
• RunTime Error '2001'
• XP Login ID
• How to open Access files and export them

Recommend Articles

• Calendar control issue in excel
• Can a field result in a Query be formatt
• PPT VBA - Automatic undo
• Disabling enter and mouse click PPT navi
• Excel VBA using ADO
• SetSourceData frustration
• Working with Visio Legend through VBA or
• macro doesn't run on open
• Referencing unregistered DLL
• Lock against application event log preve
• API (HLLAPI) errors when accessed from V
• [Excel] How to convert Excel to jpg, gif
• VBA and VB
• Event handling for dynamically created c
• File name - VBA for powerpoint