Hi,
I'm getting the "Run-time error '5': Invalid Procedure call or argument at the line below in blue: PT1.ChangePivotCache ThisWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=PTSourceRngFcst, Version:=6)
These are the values of the cells listed in the code:
G24 = \\hguwarps03\WarrenData\Finance\MANAGEMENT_REPORTS\Reforecast 2019\P06_19-Jun Reforecast\
G25 = fncl-analysis-data_May-29.xlsx
G26 = L:\Finance\MANAGEMENT_REPORTS\Reforecast 2019\P06_19-Jun Reforecast\[fncl-analysis-data_May-29.xlsx]fncl-analysis-data
Any help you can provide would be greatly appreciated. Thanks!!!
I'm getting the "Run-time error '5': Invalid Procedure call or argument at the line below in blue: PT1.ChangePivotCache ThisWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=PTSourceRngFcst, Version:=6)
These are the values of the cells listed in the code:
G24 = \\hguwarps03\WarrenData\Finance\MANAGEMENT_REPORTS\Reforecast 2019\P06_19-Jun Reforecast\
G25 = fncl-analysis-data_May-29.xlsx
G26 = L:\Finance\MANAGEMENT_REPORTS\Reforecast 2019\P06_19-Jun Reforecast\[fncl-analysis-data_May-29.xlsx]fncl-analysis-data
Any help you can provide would be greatly appreciated. Thanks!!!
Rich (BB code):
Sub Update_Sources()
'
Dim wb As Workbook, wbFromFcst As Workbook, wbFromReFcst As Workbook
Dim wkshtSourceFcst As Worksheet, wkshtSourceReFcst As Worksheet
Dim fromPathFcst As String
Dim SourceNameFcst As String
Dim PTSourcePathFcst As String
Dim rng As Range
Dim StartPointFcst As Range
Dim PTSourceRngFcst As String
Dim PT1 As PivotTable
Set wb = ThisWorkbook
fromPathFcst = Sheets("CONTROLS").Range("G24")
SourceNameFcst = Sheets("CONTROLS").Range("G25")
PTSourcePathFcst = Sheets("CONTROLS").Range("G26")
Set wbFromFcst = Workbooks.Open(fromPathFcst & SourceNameFcst)
Set wkshtSourceFcst = wbFromFcst.Sheets("fncl-analysis-data")
Set StartPointFcst = wkshtSourceFcst.Range("A1")
Set rng = wkshtSourceFcst.Range(StartPointFcst, StartPointFcst.SpecialCells(xlLastCell))
PTSourceRngFcst = PTSourcePathFcst & "!" & rng.Address(ReferenceStyle:=xlR1C1)
Set PT1 = ThisWorkbook.Sheets("Pivots").PivotTables("Customer_Cat_LocnType")
PT1.ChangePivotCache ThisWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=PTSourceRngFcst, Version:=6)
End Sub