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

Hi!

I am trying to create a general macro that will create pivot table. my
problem is how to create the "SourceData:=" and "TableDestination:="
locations in such a way that it will fit the name of the current sheet?
note: the location of the table in the sheet will be always "L1".

I tried:

Dim ws, wb As String
Dim LastRow As Long

ws = ActiveSheet.Name
wb = ThisWorkbook.Name

LastRow = Range("A" & Rows.Count).End(xlUp).Row
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"ws!R1C1:R" & LastRow & "C10").CreatePivotTable TableDestination:= _
"'[wb]ws'!R1C12", TableName:="PivotTable1",
DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Cycle_Num", _
ColumnFields:="Step_Num"
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Capacity fix")
.Orientation = xlDataField
.Caption = "Capacity fix"
.Function = xlMax
End With

But it is not working....

Thanks in advance for your help.

Eli
 
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
Print Pivot Table headers on pages with Pivot Table tsgoose Excel Worksheet Functions 0 December 9th 08 08:14 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:23 PM.

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"