Run Time Error 5 - Invalid Procedure Call or Argument Run Time Error 5 - Invalid Procedure Call or Argument vba vba

Run Time Error 5 - Invalid Procedure Call or Argument


The answer to your problem is located here.

Your sheet name in TableDestination:="LED OTTR!R1C1" needs to be surrounded with single quotes in order for it to work TableDestination:="'LED OTTR'!R1C1"

You will also have problems with the duplicated name if you do not delete this PivotTable before rerunning the code.


In my case the trouble was related to the region settings in Windows. I downloaded a (protected) xlsm file from the internet and always got the "Run Time Error 5 - Invalid Procedure Call or Argument" error when opening it. The other answer hinted to me that it may have to do with the language settings. The scripts in the file were obviously programmed in German while my Windows was set to an English region.

In Windows 10 Settings > Time & Language > Region I changed Region as well as Regional format to German. After restarting Excel, the file worked.


I've run into this, and the error was caused by calling the Worksheet.ExportAsFixedFormat method on a hidden worksheet.

I just added the if worksheet.Visible Then condition to my code to prevent getting the Invalid Procedure Call or Argument error.