I have set up a vba tool in an excel document with two exhibits on separate tabs. Each macro pulls data down from a server location and then builds pivot tables, charts, and slicers.
Both macros begin by deleting all the pivot connections, slicers, slicer caches, and pivot tables. The code is working fine as long as you run one exhibit and not the other. However, if you run the second exhibit, and then go back to run the first exhibit again, it does not delete and replace the slicers. I have tried stepping through the code to see why this might be happening, but it's just not working and I'm not getting any error messages. I have tried two methods for deleting the slicers:
WorksheetName.Shapes.Range(Array("Slicer Name")).Delete
For Each SL In WorksheetName.Shapes
If SL.Type = msoSlicer Then SL.Delete
Next SL
The SL dim is defined as a Shape, in this instance.
Again, as long as you run one exhibit and not another, the step to delete and replace the slicer works fine. This error only occurs when you run the second exhibit and then go back to the first.
Has anyone encountered a problem like this? Is there another method for deleting slicers I should try?
Thanks!