ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How to create a pivot table in a new worksheet by recording a macro (https://www.excelbanter.com/excel-worksheet-functions/349881-how-create-pivot-table-new-worksheet-recording-macro.html)

razib

How to create a pivot table in a new worksheet by recording a macro
 
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

isabelle

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






All times are GMT +1. The time now is 03:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com