jasonfish11
Board Regular
- Joined
- May 14, 2015
- Messages
- 56
All,
I've searched for the answer to my question and haven't found much help. I was hoping someone could point out where I'm missing something as the below coding fails at the last line and never creates a pivot table.
The variables of SrcData and StartPvt both appear correctly when I hover over them in VBA.
Any help would be much appreciated.
I've searched for the answer to my question and haven't found much help. I was hoping someone could point out where I'm missing something as the below coding fails at the last line and never creates a pivot table.
Code:
'Create pivot tables
Dim pvtCache As PivotCache
Dim pvt As PivotTable
Dim StartPvt As String
Dim SrcData As String
Worksheets("Combined").Select
SrcData = ActiveSheet.Name & "!" & Range("A1:E" & comLR2).Address(ReferenceStyle:=xlR1C1)
Worksheets("Recon Pivot").Select
StartPvt = ActiveSheet.Name & "!" & Range("A2").Address(ReferenceStyle:=xlR1C1)
Set pvtCache = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=SrcData)
Set pvt = pvtCache.CreatePivotTable(TableDestination:=StartPvt, TableName:="PivotTable1")
The variables of SrcData and StartPvt both appear correctly when I hover over them in VBA.
Any help would be much appreciated.
Last edited: