R
Rob
I'm having trouble programatically creating a pivot table. If I step through
the code below it works, but if I run it, it falls over on the Set PT line.
Can anyone see a problem with my code?
Thanks
Rob
Sub MakePivot(ReportName As String, DataAddress As String, ReportAddress As
Range)
Dim PTcache As PivotCache
Dim PT
Set PTcache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase,
SourceData:=DataAddress)
Set PT = PTcache.CreatePivotTable(TableDestination:=ReportAddress,
TableName:=ReportName)
the code below it works, but if I run it, it falls over on the Set PT line.
Can anyone see a problem with my code?
Thanks
Rob
Sub MakePivot(ReportName As String, DataAddress As String, ReportAddress As
Range)
Dim PTcache As PivotCache
Dim PT
Set PTcache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase,
SourceData:=DataAddress)
Set PT = PTcache.CreatePivotTable(TableDestination:=ReportAddress,
TableName:=ReportName)