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 November 18th, 2011, 05:55 AM
Registered User
 
Join Date: Nov 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default To insert Pivot table using macro

We have to insert a pivot table every week . I want to do it automatically using macro . I have a sheet bank.xls i want to insert a pivot table like on all the data . I want to put res name fiels under row labels then mon and tue fields under values . I want to write a macro for this .
Can somebody please help me with this .
 
Old November 18th, 2011, 12:41 PM
Registered User
 
Join Date: Nov 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok i wrote the below code for this thing -

Sub test()
ActiveWorkbook.Sheets("CDH006").Select
Range("A1").Select
Set objTable = Sheet1.PivotTableWizard

Set objField = objTable.PivotFields("Res")
objField.Orientation = xlRowField


Set objField = objTable.PivotFields("mon")
objField.Orientation = xlDataField

objField.Function = xlSum

Set objField = objTable.PivotFields("tue")
objField.Orientation = xlDataField
objField.Function = xlSum

ActiveSheet.PrintPreview

End Sub

Now my problem is sum value for mon and tue is coming under row labels i want it under columns . Please help me with this .
 
Old November 22nd, 2011, 12:28 PM
Registered User
 
Join Date: Nov 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Any body has come across above type of situation or like how to work on the pivot table macros ??





Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Pivot table VBA jae113 Excel VBA 2 November 18th, 2011 02:13 PM
Filter Pivot Table(s) based on Cell Value outside Pivot steplawn Beginning VB 6 0 May 11th, 2010 09:01 PM
Pivot Table vbsolo Excel VBA 3 November 23rd, 2005 01:28 AM
Pivot Table mikeparams SQL Server 2000 1 February 9th, 2005 10:10 AM
insert 2-D pivot table into a regular recordset ? cs001 SQL Server 2000 1 November 17th, 2003 08:16 AM





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