I'm getting a "Run-time error '5': Invalid procedure call or argument" when running my code (below). I cannot figure out what I'm doing wrong here. Does anyone have any suggestions?
Code:
Dim APXPvtSrcData As String
Dim APXPvtCache As PivotCache
Dim StartPvt As String
Dim APXDataRowCount As String
Dim APXPvtTable As PivotTable
Dim i As Integer
'Set pivot data range
Sheets("APX Data").Activate
Call CountRows(RowCount)
APXDataRowCount = RowCount + 2
APXPvtSrcData = Sheets("APX Data").Name & "!" & Range("A7:K" & APXDataRowCount).Address(ReferenceStyle:=xlA1)
'Set Pivot Table location
StartPvt = Sheets("APX Summary").Range("A3").Address(ReferenceStyle:=xlA1)
'Create Pivot Cashe from Source Data
Set APXPvtCache = Workbooks(OutputFile).PivotCaches.Create(xlDatabase, APXPvtSrcData)
'Create Pivot Table from Pivot Cache
Set APXPvtTable = APXPvtCache.CreatePivotTable(StartPvt, "PivotTable1")