LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
UB UB is offline
external usenet poster
 
Posts: 120
Default Pivot table using VBA

Hi
I am trying to create a pivot table using VBA.
I have a workbook in which sheet1 has data, I have a commondbutton on sheet2
and on click on this button , I am trying to create pivot table on sheet
PivotSheet
My PivotSheet gets created but with no pivot table data. Please advise what
am I doing wrong in this code

Dim ptcache As PivotCache
Dim pt As PivotTable


Application.ScreenUpdating = False

On Error Resume Next

Application.DisplayAlerts = False

Sheets("PivotSheet").Delete

On Error GoTo 0

Set ptcache = ActiveWorkbook.PivotCaches.Add( _
SourceType:=xlDatabase, _
SourceData:=Sheets("Sheet1").Range("A1").CurrentRe gion.Address)

Worksheets.Add
ActiveSheet.Name = "PivotSheet"

Set pt = ptcache.CreatePivotTable( _
TableDestination:=Sheets("PivotSheet").Range("A1") , _
TableName:="File")

With pt

.PivotFields(3).Orientation = x1RowField
.PivotFields(15).Orientation = x1ColumnField
.PivotFields(5).Orientation = x1DataField
End With

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create pivot table from existing pivot table in excel 2007 Udayraj Dhulekar Excel Discussion (Misc queries) 2 July 8th 13 08:22 PM
Pivot Table and Pivot Table dates are not in correct order ls Charts and Charting in Excel 3 July 14th 09 04:02 PM
Copying values from pivot table to cells outside pivot table richzip Excel Discussion (Misc queries) 4 January 16th 08 11:03 PM
How do I create a pivot table if the pivot table icon or menu ite. Lynn@WS Charts and Charting in Excel 1 December 16th 04 02:36 AM
Help required with setting up a pivot table with the source on sheet1 to have the pivot table created on sheet called "report" Diana[_5_] Excel Programming 0 August 21st 03 10:19 PM


All times are GMT +1. The time now is 12:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"