I new to VBA. I am trying to create pivot table for very big record(around 30K Record). This is my code for creating the pivot table. while creating the pivot table it throws error as “Type mismatch”. It was working fine for small set of records.
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=rngData, _
Version:=xlPivotTableVersion12).CreatePivotTable TableDestination:=wsPvtTbl.Range("A1"), _
TableName:="PivotTable1", DefaultVersion:=xlPivotTableVersion12
Please help me on this.
Thanks in advance
You can use something like this with your rngData variable:
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:="'" & rngData.Worksheet.name & "'!" & rngData.Address(referencestyle:=xlR1C1), _
Version:=xlPivotTableVersion12).CreatePivotTable TableDestination:=wsPvtTbl.Range("A1"), _
TableName:="PivotTable1", DefaultVersion:=xlPivotTableVersion12
Tags: excelexcel, vba