Replace
Dim xlRange As Excel.Range = CType(osheet, Excel.Worksheet).Range("C2:AE70000")
Dim ptCache As Excel.PivotCache = obook.PivotCaches.Add(XlPivotTableSourceType.xlDatabase, xlRange)
With
Dim ptCache As Excel.PivotCache = obook.PivotCaches.Add(SourceType:=Excel.XlPivotTableSourceType.xlDatabase, SourceData:="Emb!C2:AE70000")
PivotGrid Control for pivot table creation
ReplyDelete