I am trying to build a macro to create a pivot table from data in a spreadsheet. I am having trouble with one of the lines of code and I'm stumped. the line is the one below that is bolded. Any help would be appreciated.
Amy
Dim PTCache As PivotCache
Dim PT As PivotTable
Dim PRange As Range
' Define input area and set up a Pivot Table Cache
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
Set PRange = Cells(1, 1).Resize(finalrow, 4)
Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:="PRange")
Set PT = PTCache.CreatePivotTable(TableDestination:=Cells(1, 6), TableName:="PivotTable1")
Amy
Dim PTCache As PivotCache
Dim PT As PivotTable
Dim PRange As Range
' Define input area and set up a Pivot Table Cache
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
Set PRange = Cells(1, 1).Resize(finalrow, 4)
Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:="PRange")
Set PT = PTCache.CreatePivotTable(TableDestination:=Cells(1, 6), TableName:="PivotTable1")