troubleshooting Question

Pivot madness Excel 2007

Avatar of Natchiket
NatchiketFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft Excel
7 Comments1 Solution367 ViewsLast Modified:
I have an application which creates lots of pivot tables and then copies the numeric values into another worksheet for formatting. it works fine for many iterations and then errors on the line

Set ptl=mwksPT.PivotTables.Add(PivotCache:=ptc,tabledestination:=mwksPT.Cells(mlngPTRow, 2))

with the error Error (1004): Reference is not valid.

mlngPTRow has a value of 47.  And if I look in the worksheet I can see that the row is clear.  However, something seriously bad has happened if you look at the screenshot, down at row 59 something spooky is going on .. another worksheet is manifesting behind 'PivotTables'

If Len(mstrFCol) > 0 Then
    Set ptc = mwkb.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=mwkb.Worksheets(mstrSD).Cells(1, 1).CurrentRegion.SpecialCells(xlCellTypeVisible))
    Set ptc = mwkb.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=mwkb.Worksheets(mstrSD).Cells(1, 1).CurrentRegion)
End If
Set ptl = mwksPT.PivotTables.Add(PivotCache:=ptc, tabledestination:=mwksPT.Cells(mlngPTRow, 2))
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros