30 Advanced Excel Tips for 2026

Excel Champs / VBA / VBA Error 400 (How to Fix it)
By Puneet Gogia (Microsoft MVP)

VBA Error 400 (How to Fix it)

Error 400 in VBA means “Form already displayed; can’t show modal”: the code calls UserForm1.Show for a form that’s already on screen. Check whether it’s visible before showing it:

If Not UserForm1.Visible Then UserForm1.Show

Excel also shows a plain message box reading only “400” when some macros run from a button or the Macros dialog fail, without saying what went wrong. To find the real error, open the Visual Basic Editor (Alt + F11), click inside the macro and press F8 to step through it; the line that fails shows the actual error number and message.

If the code runs cleanly when you step through it but still shows 400 from the button, copy the code into a new module (Insert → Module) and delete the old one. That clears a damaged module, a fix that often works for the bare 400 box.

Add an error handler, On Error GoTo with MsgBox Err.Number & ": " & Err.Description after the label, so the next failure names the real error instead of showing 400.

What is Error 400 in VBA

Error 400 in VBA is like a message “something’s not right” that pops up when your Excel macro runs into a problem. It doesn’t give you specific details about what went wrong, so it can be tricky to figure out. This error often happens if there’s an issue with how the macro interacts with Excel, like trying to do something that isn’t allowed or possible at the moment.

It is a runtime error that is not so common, but there are a few situations where you could face this error. This error occurs when Microsoft Excel crashes or fails while running a macro.

And different reasons can make Excel crash or fails:

  • If your macro tries to access a range or a cell incorrectly (e.g., referencing a non-existent range), this might trigger the error. Check your range references and ensure they are valid.
  • If you recently installed new add-ins, they might conflict with your macro.
  • Changing UserForms inappropriately (like unloading them incorrectly) might cause this error. Review how UserForms are managed in your code.
  • A corrupted global template in Excel can also lead to Error 400.
  • Deficient in the installation of Microsoft Excel.
  • Excel failed to read or write from a file or try to access an object that does not exist or moved.
  • The macro that you are trying to execute is corrupt.
  • Or there could be a possibility of having a virus or malware in this system.

It appears as a simple message box displaying “400” with no further details.

How to Fix VBA Error 400

It is a little tricky to fix the error 400 as it doesn’t come with any notification that is what is causing it. but you can use a few ways to fix it.

Debug the code and execute each line of code 1 by 1

Debugging a code by executing each line one at a time is a great way to understand how your code works and find where errors occur.

  • Step Into (F8): This button lets you execute your code line by line. When a line calls a subroutine or function, stepping in will take you into that subroutine or function.
  • Step Over (Shift + F8): This executes the following line of code but doesn’t enter any called procedures. Instead, it executes them in the background and moves to the following line in the procedure.
  • Step Out (Ctrl + Shift + F8): If you are inside a subroutine or function, this will run the rest and pause once it returns to the calling procedure.

Apart from that, there could be a possibility of having a virus or malware that can cause this error. So, you can also use an antivirus to scan your system and all the files that you are trying to access the macro.

Puneet Gogia

Written by

Puneet Gogia

Microsoft MVP — Excel · Founder, Excel Champs

Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.

3M+ readers helped
1,000+ tutorials written
Since 2015 teaching Excel
Author Photo

My name is Puneet and I am the founder of ExcelChamps.com. I have been awarded Microsoft MVP for Excel for my contribution to the Excel Community through this blog, YouTube Channel, and LinkedIn.