View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
isabelle isabelle is offline
external usenet poster
 
Posts: 587
Default How to create a pivot table in a new worksheet by recording amacro

hi ,

for example with the following data:
range(A1:C5) name: rng


aa bb cc
a1 b1 1
a2 b2 2
a3 b3 3
a4 b4 4


Sub Macro1()
Dim x As String
x = Range("rng")(3)

With ActiveSheet

'PivotTableWizard xlDatabase, names of source range, destination range, name

..PivotTableWizard xlDatabase, Range("rng"), .Range("E6"), "TCD1"

With .PivotTables(1)
.AddFields RowFields:=Range("rng")(1), ColumnFields:=Range("rng")(2)
.PivotFields(x).Orientation = xlDataField
End With

End With
ActiveWorkbook.ShowPivotTableFieldList = False
End Sub




--
isabelle



Le 2012-01-26 03:43, razib a écrit :
Hey guys,

I am a new member of this forum. I liked the forum.

Right now I am trying to run a macro which will create a pivot table in
a new worksheet. I was trying by recording a macro. But it does not
work.

Anybody pls help.

Razib