I saved this macro to the personal folder, but it still does not work for any workbook that I want to use it in. What's wrong with it?
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"DynamicRange", Version:=xlPivotTableVersion10).CreatePivotTable _
TableDestination:="'Employee Roster- Active Employe'!R1C25", TableName:= _
"PivotTable2", DefaultVersion:=xlPivotTableVersion10
Sheets("Employee Roster- Active Employe").Select
Cells(1, 25).Select
ActiveWorkbook.ShowPivotTableFieldList = True
ActiveWindow.ScrollColumn = 20
ActiveWindow.ScrollColumn = 21
ActiveWindow.ScrollColumn = 22
ActiveWindow.ScrollColumn = 23
With ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"Cost_Center_(Division)")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Department")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("Employee_Number"), "Count of Employee_Number", _
xlCount
End Sub
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"DynamicRange", Version:=xlPivotTableVersion10).CreatePivotTable _
TableDestination:="'Employee Roster- Active Employe'!R1C25", TableName:= _
"PivotTable2", DefaultVersion:=xlPivotTableVersion10
Sheets("Employee Roster- Active Employe").Select
Cells(1, 25).Select
ActiveWorkbook.ShowPivotTableFieldList = True
ActiveWindow.ScrollColumn = 20
ActiveWindow.ScrollColumn = 21
ActiveWindow.ScrollColumn = 22
ActiveWindow.ScrollColumn = 23
With ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"Cost_Center_(Division)")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Department")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("Employee_Number"), "Count of Employee_Number", _
xlCount
End Sub