Hey Mike,
My apologies for thinking your method wouldn't work. After doing more research last night and this AM on what Dynamic Ranges were, I fully understand what you were talking about now. I tested it, rebuilt the macro, and it worked perfectly! Now onto the next step of this project.
Just in case anyone else was wondering how it was done, I've posted the code below:
' Create DynamicRange name BacklogRange
ActiveWorkbook.Names.Add Name:="BacklogRange", RefersToR1C1:= _
"=OFFSET(Sheet1!R1C1,0,0,COUNTA(Sheet1!C1,4))"
ActiveWorkbook.Names("BacklogRange").Comment = ""
With ActiveWorkbook.Names("BacklogRange")
.Name = "BacklogRange"
.RefersToR1C1 = "=OFFSET(Sheet1!R1C1,0,0,COUNTA(Sheet1!C1),4)"
.Comment = ""
End With
' Create Pivot Table
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"BacklogRange", Version:=xlPivotTableVersion10).CreatePivotTable _
TableDestination:="Sheet2!R3C1", TableName:="PivotTable4", DefaultVersion _
:=xlPivotTableVersion10
Sheets("Sheet2").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable4").PivotFields("Invt ID")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable4").AddDataField ActiveSheet.PivotTables( _
"PivotTable4").PivotFields("BO qty"), "Sum of BO qty", xlSum
ActiveWorkbook.ShowPivotTableFieldList = False
Thanks again Mike!
Bookmarks