Thanks for any input on this. I\'m trying to make a simple pivot table that is taking data from sheet \"5 Month Trending May 15\" and putting it onto my Pivot Table sheet ca
The documentation for PivotCaches.Create indicates
The
SourceDataargument is required ifSourceTypeisn'txlExternal. It can be aRangeobject (whenSourceTypeis eitherxlConsolidationorxlDatabase) or an Excel Workbook Connection object (whenSourceTypeisxlExternal).
Despite this, the macro recorder will always create a String here for the SourceData. (It will even create a bad string if the Sheet has a space in the name).
Given the preference for the macro recorder, I often supply this as a String with the addresses.
I have been able before to supply a Range here so I am not certain what is specifically going on that prevents the Range usage in this case.
To use a String, your code would look like:
Set pvtCache = ActiveWorkbook.PivotCaches.Create(xlDatabase, "'5 Month Trending May 15'!A2:H38")