allstarrunner
New Member
- Joined
- May 29, 2012
- Messages
- 34
Hello and thank you in advance for your help! I have tried to figure this one out, but I am at a loss. I am trying to make a simple Pivot Table from Column E which will open a new sheet and then show two columns in the pivot, the first column (Column A on the new spreadsheet) which has the names from column E and then Column B (on the new Spreadsheet) which shows the count of the names from column E. But I keep getting a "Reference not found Error" (Shown in Bold) The name of the sheet that contains Column E is "Data Dump". I have Windows 7 and use Excel 2007.
Here is the code I have:
Here is the code I have:
Rich (BB code):
' Name the Range and Create Pivot Table
ActiveWorkbook.Names.Add Name:="DataDumpPivot", RefersToR1C1:= _
"=OFFSET(DataDump!R1C5,0,0,COUNTA(DataDump!C5),1)"
ActiveWorkbook.Names("DataDumpPivot").Comment = ""
Range("A1").Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"DataDumpPivot", Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="", TableName:="PivotTable4", _
DefaultVersion:=xlPivotTableVersion12
ActiveSheet.Select
Cells(1, 1).Select
With ActiveSheet.PivotTables("PivotTable4").PivotFields( _
"Dept Name and Dept Num")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable4").AddDataField ActiveSheet.PivotTables( _
"PivotTable4").PivotFields("Dept Name and Dept Num"), _
"Count of Dept Name and Dept Num", xlCount
With ActiveSheet.PivotTables("PivotTable4").PivotFields( _
"Dept Name and Dept Num")
.Orientation = xlRowField
.Position = 1
End With
Range("B6").Select
ActiveSheet.PivotTables("PivotTable4").PivotFields("Dept Name and Dept Num"). _
AutoSort xlDescending, "Count of Dept Name and Dept Num", ActiveSheet. _
PivotTables("PivotTable4").PivotColumnAxis.PivotLines(1), 1