plz anyone do help me
....its very urgent...
I created a macro for creating Pivot table. But when i Run it, it shows Error.
Every time i have new data with changed Data range with different sheet range.I want to create macro such that it can be used in general for creating Pivot Table in new sheet having any name and also having any range..
I am using Ms excel 2007
The coding used by me containing Error, Plz Plz Fix it
Sub Macro3()
'
' Macro3 Macro
'
'
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
DataSheet = ActiveSheet.Name
Sheets.Add
NewSheet = ActiveSheet.Name
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
DataSheet & "!A1C1:C" & FinalRow & "C12", Version:=xlPivotTableVersion10).PivotCache.CreatePivotTable
TableDestination:=NewSheet & "!R3C1", DefaultVersion:=xlPivotTableVersion10
Sheets(NewSheet).Select
Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
"PivotTable3").PivotFields("Data"), "Sum of Data", xlSum
With ActiveSheet.PivotTables("PivotTable3").PivotFields("Patic")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
"PivotTable3").PivotFields("Amt"), "Sum of Amt", xlSum
With ActiveSheet.PivotTables("PivotTable3").DataPivotField
.Orientation = xlColumnField
.Position = 1
End With
ActiveCell.Select
End Sub
What to Do......???????

I created a macro for creating Pivot table. But when i Run it, it shows Error.
Every time i have new data with changed Data range with different sheet range.I want to create macro such that it can be used in general for creating Pivot Table in new sheet having any name and also having any range..
I am using Ms excel 2007
The coding used by me containing Error, Plz Plz Fix it

Sub Macro3()
'
' Macro3 Macro
'
'
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
DataSheet = ActiveSheet.Name
Sheets.Add
NewSheet = ActiveSheet.Name
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
DataSheet & "!A1C1:C" & FinalRow & "C12", Version:=xlPivotTableVersion10).PivotCache.CreatePivotTable
TableDestination:=NewSheet & "!R3C1", DefaultVersion:=xlPivotTableVersion10
Sheets(NewSheet).Select
Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
"PivotTable3").PivotFields("Data"), "Sum of Data", xlSum
With ActiveSheet.PivotTables("PivotTable3").PivotFields("Patic")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
"PivotTable3").PivotFields("Amt"), "Sum of Amt", xlSum
With ActiveSheet.PivotTables("PivotTable3").DataPivotField
.Orientation = xlColumnField
.Position = 1
End With
ActiveCell.Select
End Sub
What to Do......???????