How to create a pivot table in a new worksheet by recording a macro

R

razib

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 i
a new worksheet. I was trying by recording a macro. But it does no
work.

Anybody pls help.

Razi
 
I

isabelle

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 :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top