Home

Macro Error for Pivot Table

%3CLINGO-SUB%20id%3D%22lingo-sub-1030803%22%20slang%3D%22en-US%22%3EMacro%20Error%20for%20Pivot%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1030803%22%20slang%3D%22en-US%22%3E%3CP%3EI%20can%20create%20a%20Pivot%20Table%20for%20the%20data%20I%20download%20and%20it%20works%20fine.%3C%2FP%3E%3CP%3EHowever%2C%20when%20I%20made%20a%20Macro%20to%20do%20the%20same%20thing%2C%20I%20get%20an%20error.%20The%20error%20is%3A%20Run-time%20error%20'5'%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20following%20is%20a%20screenshot%20of%20the%20highlighted%20error%20in%20the%20Macro.%20I%20am%20now%20using%20Excel%202013%2C%20however%20I%20made%26nbsp%3Ban%20initial%20Macro%20using%20an%20older%20version%20of%20Excel%20and%20am%20now%20trying%20to%20make%20a%20pivot%20table%20using%202013%20and%20installing%20it%20near%20the%20start%20of%20the%20existing%20Macro%20I%20have.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F158782i6E17BB9A04D4B281%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Error%20in%20Macro.PNG%22%20title%3D%22Error%20in%20Macro.PNG%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EMacro%20Error%20for%20Pivot%20Table%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EHow%20do%20I%20correct%20for%20this%20error%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1030803%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1031907%22%20slang%3D%22en-US%22%3ERe%3A%20Macro%20Error%20for%20Pivot%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1031907%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F420240%22%20target%3D%22_blank%22%3E%40WayneEK%3C%2FA%3E%26nbsp%3BDoes%20%22Table1%22%20exist%3F%20And%20what%20about%20the%20destination%20%22Contract1%20Report%22%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20either%20one%20of%20those%20doesn't%20exist%2C%20or%20is%20even%20spelled%20differently%2C%20then%20that%20would%20cause%20the%20code%20to%20bug.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1032330%22%20slang%3D%22en-US%22%3ERe%3A%20Macro%20Error%20for%20Pivot%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1032330%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20replying.%20I%20confirmed%20the%20spelling%20and%20reference%20to%20the%20sheet%20and%20table%20is%20correct%20but%20am%20still%20getting%20the%20error.%20The%20only%20thing%20I%20can%20think%20it%20might%20be%20is%20that%20I%20should%20create%20a%20separate%20Sheet%20to%20put%20the%20Pivot%20Table%20on%2C%20instead%20of%20the%20existing%20sheet%20that%20the%20table%20is%20on.%20Thanks%20anyways.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1074953%22%20slang%3D%22en-US%22%3ERe%3A%20Macro%20Error%20for%20Pivot%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1074953%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F420240%22%20target%3D%22_blank%22%3E%40WayneEK%3C%2FA%3E%26nbsp%3Btry%20recording%20a%20new%20macro%20to%20create%20the%20pivot%20table%20then%20compare%20both%20codes%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
WayneEK
Occasional Contributor

I can create a Pivot Table for the data I download and it works fine.

However, when I made a Macro to do the same thing, I get an error. The error is: Run-time error '5':

 

The following is a screenshot of the highlighted error in the Macro. I am now using Excel 2013, however I made an initial Macro using an older version of Excel and am now trying to make a pivot table using 2013 and installing it near the start of the existing Macro I have.

Error in Macro.PNGMacro Error for Pivot Table

How do I correct for this error?

3 Replies

@WayneEK Does "Table1" exist? And what about the destination "Contract1 Report"?

 

If either one of those doesn't exist, or is even spelled differently, then that would cause the code to bug.

Thanks for replying. I confirmed the spelling and reference to the sheet and table is correct but am still getting the error. The only thing I can think it might be is that I should create a separate Sheet to put the Pivot Table on, instead of the existing sheet that the table is on. Thanks anyways.

@WayneEK try recording a new macro to create the pivot table then compare both codes

Related Conversations
PivotTable : Unexpected behavior with 2 tables
CastyChichi in Excel on
2 Replies
Edge Insider doesn't show notifications
ThatWeirdAndrew in Discussions on
10 Replies
Problem to start Teams in the browser
André Diekmann in Microsoft Teams on
9 Replies
Set Auto Refresh to Pivot Table as Source Data Changes
ratishkp in Excel on
2 Replies
Counting Days
Tim Hunter in SQL Server on
2 Replies