i'm trying to fetch the Data from a PivotTable, use it in Array in VBA and then to print it. I'm new to VBA and I've watched a few tutorials, but i can't actually get it.
I've tried with referencing the range of my column with "DataBodyRange", but i always get different errors. "Sheet4" is the sheet where my "PivotTable1" is located. And i need all the data from a column.
Public Sub ReadToArray()
'Range
Dim rg As Range
Set rg = Worksheets("Sheet4").pt("PivotTable1").DataBodyRange
'Dynamic Array
Dim Done As Variant
Done = rg.Value
'Array Values
Debug.Print "i", "Value"
Dim i As Long
For i = LBound(Done) To UBound(Done)
Debug.Print i, Done(i)
Next i
End Sub
The end result is that I want to print out the values for the whole column and use them afterwards.