praveen.kagitala
New Member
- Joined
- Jun 15, 2012
- Messages
- 1
Hi,
I am not a programmer and does not have much knowledge on programming. But looking through various forums i have tried recording a macro when creating a Pivot table assuming that I can use the same on differnt excel sheet. But unfortunately when ever I use the code, it creates a different sheet name and the code does not execute.
Here is the code which is recorded:
Sub PivotTableMacro()
'
' PivotTableMacro Macro
'
'
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R1959C25", Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="Sheet6!R3C1", TableName:="PivotTable1", DefaultVersion _
:=xlPivotTableVersion12
Sheets("Sheet6").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Month")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Priority*")
.Orientation = xlRowField
.Position = 2
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Incident ID*+"), "Count of Incident ID*+", xlCount
Range("A4:B27").Select
ActiveSheet.PivotTables("PivotTable1").PivotSelect "Month[All]", xlLabelOnly + _
xlFirstRow, True
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Sheet6'!$A$3:$B$29")
ActiveWorkbook.ShowPivotChartActiveFields = True
ActiveChart.ChartType = xlLineMarkers
End Sub
Would any please help me designing this code
I am not a programmer and does not have much knowledge on programming. But looking through various forums i have tried recording a macro when creating a Pivot table assuming that I can use the same on differnt excel sheet. But unfortunately when ever I use the code, it creates a different sheet name and the code does not execute.
Here is the code which is recorded:
Sub PivotTableMacro()
'
' PivotTableMacro Macro
'
'
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R1959C25", Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="Sheet6!R3C1", TableName:="PivotTable1", DefaultVersion _
:=xlPivotTableVersion12
Sheets("Sheet6").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Month")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Priority*")
.Orientation = xlRowField
.Position = 2
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Incident ID*+"), "Count of Incident ID*+", xlCount
Range("A4:B27").Select
ActiveSheet.PivotTables("PivotTable1").PivotSelect "Month[All]", xlLabelOnly + _
xlFirstRow, True
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Sheet6'!$A$3:$B$29")
ActiveWorkbook.ShowPivotChartActiveFields = True
ActiveChart.ChartType = xlLineMarkers
End Sub
Would any please help me designing this code