travesseiro
New Member
- Joined
- Dec 16, 2021
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hello everyone!
I looked everywhere but did not found anything that fixes this thing!
Im creating a pivot table as it follows:
I keep getting error 13 at the "Set pvt" line, what is wrong here?
Thanks in advance!
I looked everywhere but did not found anything that fixes this thing!
Im creating a pivot table as it follows:
VBA Code:
Dim pvt As PivotCache
Dim leftCorner As Range
Dim rightCorner As Range
Dim completeTable As String
Dim destination As String
Set leftCorner = Cells(1, "B").End(xlDown)
Set rightCorner = Cells(Rows.Count, "B").End(xlUp).Offset(, 5)
completeTable = ActiveSheet.Name & "!" & Range(leftCorner, rightCorner).Address(ReferenceStyle:=xlR1C1)
Worksheets("DataTreatment").Activate
destination = ActiveSheet.Name & "!" & Range("B4").Address(ReferenceStyle:=xlR1C1)
Set pvt = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=completeTable, Version:=7). _
CreatePivotTable(TableDestination:=destination, _
TableName:="Tabela dinâmica2")
I keep getting error 13 at the "Set pvt" line, what is wrong here?
Thanks in advance!