Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 13th, 2004, 05:53 PM
dmw dmw is offline
Registered User
 
Join Date: Apr 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Generate Pivot Tables using variables

I'm trying to create a pivot table using variables (my first time coding pivot tables). On Excel 2002, the following works (NOTE: I've named the data range in the source worksheet = "TesterDB"):
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _
        SourceData:=SourceWks.Range("TesterDB")). _
        CreatePivotTable TableDestination:= _
        DestWks.Range("A1"), TableName:="MyFirstPivot"

Unfortunately, my company is using Excel 2000 so I've modified the above to:
    MySource = RootDirectory & "[Source.xls]Sheet3!R1C1:R1470C17"
    MyDest = "Sheet1!R1C1"
    ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _
        SourceData:=MySource). _
        CreatePivotTable TableDestination:= _
        MyDest, TableName:=PTTableName

This doesn't allow me to change the destination of the pivot table (it gets dumped into the source spreadsheet). So I have 3 different workbooks involved: the current active workbook, a separate source workbook, and a separate destination workbook. There must be a way to use variables to access these...Could someone please direct me?

Thank you,
DMW
Toronto, Canada






Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA for Pivot Tables stealthdevil Excel VBA 3 March 21st, 2007 04:01 PM
how to work pivot tables malli_kv2 Access 1 March 16th, 2007 06:34 AM
Linking pivot tables iacon Excel VBA 3 July 24th, 2006 01:25 AM
International Pivot Tables noldrini Excel VBA 0 February 8th, 2006 12:54 PM
Pivot Tables smartgir Excel VBA 0 May 12th, 2004 10:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.