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 June 27th, 2005, 04:26 AM
Authorized User
Join Date: Jun 2005
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help Needed to write vba for Pivot Table in Excel


I need to create a pivot table based on 4 criteria. But the no. of rows containing the data may vary from time to time. I know I can make use of currentregion property to determine the no. of rows but how do I incorporate it into the macro for pivot table?

The code for the pivot table is as follows:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
        "Trade_Participants!C1:R89C4").CreatePivotTabl e TableDestination:="", _
        TableName:="PivotTable11", DefaultVersion:=xlPivotTableVersion10
    ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
    ActiveSheet.Cells(3, 1).Select
    ActiveSheet.PivotTables("PivotTable11").ColumnGran d = False
    ActiveSheet.PivotTables("PivotTable11").AddFields RowFields:="mem_code", _
        ColumnFields:=Array("comm_code", "trd_type")
    ActiveSheet.PivotTables("PivotTable11").PivotField s("Sum Of match_qty"). _
        Orientation = xlDataField
    ActiveWorkbook.ShowPivotTableFieldList = True
    ActiveWorkbook.ShowPivotTableFieldList = False


Old June 28th, 2005, 01:44 AM
Friend of Wrox
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts

Try this SourceData

SourceData:=Sheets("Trade_Participants").Range("A1 ").CurrentRegion


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA for Pivot Tables stealthdevil Excel VBA 3 March 21st, 2007 04:01 PM
drop Oracle table from VBA excel reipereira VB Databases Basics 0 February 2nd, 2006 01:01 PM
How to replace pivot table data fields using VBA? rstober Excel VBA 2 August 19th, 2005 06:06 AM
Saving Excel VBA code gives problems - Help needed mjaitly Excel VBA 0 April 14th, 2004 07:23 AM
Pivot Table ramdasu Excel VBA 0 October 23rd, 2003 03:16 AM

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