Share via

Runtime Error in Excel Macro Containing Insert Pivot Table

Anonymous
2021-12-02T17:54:11+00:00

When I run a recorded Excel macro containing "Insert Pivot Table" , I get "runtime error 1004: Application-Defined or Object-Defined error". I have researched the error code and I have not been able to find a fix. What am I doing wrong? Can anyone help? Below is Debugger image.

Microsoft 365 and Office | Excel | Other | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2021-12-02T20:21:37+00:00

    I created a 4 element table - 2 columns with labels, 2 rows with numbers as a test. I start Recording a Macro, Insert Pivot Table, Stop Recording, Run Macro. It fails with runtime error. Very simple to reproduce.

    thanx

    Rich

    Was this answer helpful?

    0 comments No comments
  2. HansV 462.6K Reputation points
    2021-12-02T20:08:16+00:00

    Could you create a stripped-down copy of the workbook (without sensitive information) and make it available through one of the websites that let you upload and share a file, such as OneDrive, Google Drive, FileDropper or DropBox. Then post a link to the uploaded and shared file here.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2021-12-02T20:05:37+00:00

    Does not work. Get a Compile error and Syntax error.

    Was this answer helpful?

    0 comments No comments
  4. HansV 462.6K Reputation points
    2021-12-02T19:28:30+00:00

    Use

    ..., SourceData:= \_  
        "'items-2021-11-01-2021-12-01'!R1C1:R104C26", ...
    

    i.e. with single quotes (apostrophes) around the sheet name.

    Was this answer helpful?

    0 comments No comments