TopLearner
Board Regular
- Joined
- Feb 25, 2022
- Messages
- 57
- Office Version
- 365
- Platform
- Windows
Hello there,
I hope you are well.
I have data on sheet “Sheet1”
I would like to create a pivot table on a separate tab called "Pivot" with this data using VBA. I have already tried but without success.
"Sheet1" tab
"Pivot" tab
I would like to present the table in tabular form. I get stuck with the code.
I am hoping you can help me by providing the code.
Thanks
Sanchez
I hope you are well.
I have data on sheet “Sheet1”
I would like to create a pivot table on a separate tab called "Pivot" with this data using VBA. I have already tried but without success.
"Sheet1" tab
"Pivot" tab
I would like to present the table in tabular form. I get stuck with the code.
VBA Code:
Dim ws As Worksheet
Dim newws As Worksheet
Dim PTcache As PivotCache
Dim PT As PivotTable
Dim Pivrang As String
Dim Startpiv As String
Set ws = ActiveSheet
Pivrang = ws.Activate. Address(ReferenceStyle:=xlR1C1)
Cells.Select
Set news = Sheets.Add
Startpiv = ws.Range (“A3”). Address(ReferenceStyle:=xlR1C1)
Set pvtCache = ActiveWorkbook.PivotCaches.Create( _
SourceType:=xlDatabase, _
SourceData:=SrcData)
Set pvt = pvtCache.CreatePivotTable( _
TableDestination:=StartPvt, _
TableName:="PivotTable1")
I am hoping you can help me by providing the code.
Thanks
Sanchez