B
BenKoeppen
Hi,
I want to create a pivot cache using VBA. If I write
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=
_
"A1:AC3167").CreatePivotTable TableDestination:="", _
TableName:="myPivotTable",
DefaultVersion:=xlPivotTableVersion10
it works. But if I write
myLastRow = Range("A1").End(xlDown).Row
myLastColumn = Range("A1").End(xlToRight).column
myRange = Range(Cells(1, 1), Cells(myLastRow, myLastColumn))
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase,
SourceData:= _
myRange).CreatePivotTable TableDestination:="", _
TableName:="myPivotTable",
DefaultVersion:=xlPivotTableVersion10
I get an "Type Mismatch" error. I tried various structures from for
the myRange, but none worked.
Any help apreciated.
Ben
I want to create a pivot cache using VBA. If I write
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=
_
"A1:AC3167").CreatePivotTable TableDestination:="", _
TableName:="myPivotTable",
DefaultVersion:=xlPivotTableVersion10
it works. But if I write
myLastRow = Range("A1").End(xlDown).Row
myLastColumn = Range("A1").End(xlToRight).column
myRange = Range(Cells(1, 1), Cells(myLastRow, myLastColumn))
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase,
SourceData:= _
myRange).CreatePivotTable TableDestination:="", _
TableName:="myPivotTable",
DefaultVersion:=xlPivotTableVersion10
I get an "Type Mismatch" error. I tried various structures from for
the myRange, but none worked.
Any help apreciated.
Ben