In this article, we are going to discuss methods on how to fix VBA error 400 in Excel. The error 400 in Excel usually occurs while running a Microsoft Visual Basic for Applications (VBA) macro. It causes the macros to crash or fail to run and return an error 400 message. Now, there can be different reasons for such an error; let us discuss them.
What causes VBA error 400 in Excel?
Here are the reasons due to which error 400 is triggered when running a Macro in Excel:
- Faulty installation of the Office software.
- There is some error in the VBA code.
- Invalid value in the argument.
- The running macro is corrupted.
- Excel-related files infected by some malware.
- Failure to read/ write from a file.
- Invalid registry entries.
If you are encountering error 400 in Excel, you can use the below-listed solutions to resolve it.
How to fix VBA error 400 in Excel
Here are the methods to fix error 400 encountered while running a macro in Excel:
- Move Macros to a new Module.
- Enable trusted access to VBA.
- Review your VBA code.
- Repair Microsoft Excel.
- Uninstall, and then reinstall Excel.
- Some other methods like scan for malware, etc.
Let us discuss these methods elaborately.
1] Move Macros to a new Module
Transferring your macros to a new module may fix the issue in case there is some external error. You can use the below steps to do so:
Go to the Developers tab and click on the Visual editor option. In case you don’t see the Developers tab on the main ribbon in Excel, go to File > Options and from Customize Ribbons tab, turn on the Developers checkbox from the Main Tabs section.
Now, in the Microsoft Visual Basic for Applications window, click on the Insert menu and then the Module option.
After that, paste your Macro code into this new module and save it using the dedicated option from the File menu.
Also, you need to delete the old module by right-clicking it and using the Remove option.
At last, click the File > Close and Return to Microsoft Excel option and see if the error 400 is resolved in Excel.
2] Enable trusted access to VBA
You can turn on the trusted access to VBA and see if the issue is gone. Here are the steps to enable trusted access to VBA:
- Move to the Developers tab and click on the Macros Security option.
- In the Trust Centre window, enable the option named Trusted access to the VBA project object model.
- Press the OK button.
3] Review your code
An error in VBA code can trigger error 400 in Excel. So, you need to thoroughly review the macro code and correct the error in the code if any. Also, check macros if there is any corruption.
4] Repair Microsoft Excel
If none of the above works, the problem might be with the Excel app. The application might be installed incorrectly or something needs to be repaired. So, repair Microsoft Excel using the below steps:
- Launch Settings app and go to Apps > Apps & features.
- On the right, locate and click Office 365/ Microsoft 365 program.
- Tap on the Modify button and then select Online Repair or Quick Repair option.
- Press the Repair button which repairs Excel and other Office apps.
5] Uninstall, and then reinstall Excel
You can also try to uninstall and then reinstall Office and Excel software to start afresh. See if this fixes up the error.
6] Some Other Methods
Also, some other solutions may also work like:
- You can try running an SFC scan to check and repair corrupted system files.
- Some malicious programs can also cause this error. So, check and remove malware and suspicious application with Microsoft Defender or third-party antivirus or antimalware program.
- Try deleting corrupted cache data and system junk files.
Hope the above solutions help!
Now read: How to Fix Runtime Error 1004 in Excel