Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 27th, 2005, 04:26 AM
Authorized User
Points: 172, Level: 3
Points: 172, Level: 3 Points: 172, Level: 3 Points: 172, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: Singapore, , Singapore.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help Needed to write vba for Pivot Table in Excel

Hi,

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

Thanks

Reply With Quote
  #2 (permalink)  
Old June 28th, 2005, 01:44 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: , , Finland.
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this SourceData

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

-vemaju

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:00 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.