dbmathis
Well-known Member
- Joined
- Sep 22, 2002
- Messages
- 1,064
This is some code that I recorded and then tried to modify so that I could run it as a module. This errors out right within the first With statement. Dores anyone see what is wrong with this code?
Thanks for any help.
Code:
Sub Test()
With ActiveWorkbook.Sheets("Raw Data")
.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"'Raw Data'!R1C1:R2048C36").CreatePivotTable TableDestination:= _
"[Reports.xls]Results!R6C2", TableName:="PivotTable1", DefaultVersion:= _
xlPivotTableVersion10
End With
With ActiveWorkbook.Sheets("Results")
.ShowPivotTableFieldList = True
.PivotTables("PivotTable1").PivotFields ("Product Type")
.Orientation = xlRowField
.Position = 1
.PivotTables("PivotTable1").AddDataField Sheets("results").PivotTables( _
"PivotTable1").PivotFields("EUHD Handle Time"), "Sum of EUHD Handle Time", _
xlSum
.[C8].Sort Key1:="R8C3", Order1:=xlDescending, Type:=xlSortValues, _
OrderCustom:=1, Orientation:=xlTopToBottom
' .Range("B8:C73").Select
' Selection.Copy
.Range("B8:C73").Copy
End With
With Sheets("Filtered Data")
.[B11].PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End With
End Sub
Thanks for any help.