Excel VBA Error 400: Meaning, Causes, and How to Fix It

VBA & macros · Updated November 20, 2026

In Excel VBA, error 400 means “Form already displayed; can’t show modally.” It usually appears when code tries to show a UserForm as a modal window while that form is already displayed modelessly. Close or unload the existing form before showing it modally, or keep using it modelessly. This is a VBA runtime error, not an HTTP error or a worksheet formula error.

What error 400 means

Error 400 is a numbered Visual Basic for Applications runtime error. In English-language VBA, its standard description is “Form already displayed; can’t show modally.” The message refers to the display state of a UserForm: VBA is being asked to make the form modal, but the form is already on screen in a way that prevents that change.

The number and message are built into VBA’s error system; “error 400” is not slang, an informal Excel term, or a separate feature name. It is reasonable to say, “The macro raised VBA error 400 when it tried to show the form modally.” In that sentence, the phrase identifies the runtime error and its context. The error number comes from the Visual Basic/VBA error numbering system, rather than from a code written in a workbook or an Excel cell.

The wording can differ if Office displays errors in another language, and a program can also catch the error and show its own message. The number is useful for diagnosis, but the exact form state and the line of VBA that triggered it provide the practical explanation.

How modal and modeless UserForms work

A UserForm is a custom dialog window created in the Visual Basic Editor. Its Show method controls whether it is modal or modeless:

  • UserForm1.Show vbModal displays a modal form. The calling VBA procedure pauses until the form is hidden or unloaded, and the user generally cannot interact with other parts of the same Excel application while the dialog is active. vbModal is the default if no mode is supplied.
  • UserForm1.Show vbModeless displays a modeless form. The macro continues, and the user can return to the workbook while the form remains open.

The conflict behind error 400 is a request to display a form modally when it is already displayed modelessly. A form’s display mode is not something VBA can simply switch by calling Show vbModal again. The existing display needs to end before the form is shown again with a different mode.

This matters in real macros because forms are often launched from buttons, ribbon controls, worksheet events, or other forms. A second launch path may run while a modeless window is still open. The code may look like an ordinary call to Show, but the form’s current state is what determines whether the call succeeds.

Common situations that cause error 400

A typical sequence is to show a form modelessly, leave it open, then call the same form modally. The second call attempts to use a display mode that conflicts with the form’s existing display. Similar problems can happen when separate procedures both try to open the same default UserForm instance and one assumes it is not already visible.

For example, the following demonstration intentionally makes the conflicting calls. Save a copy of the workbook before running any macro; VBA changes cannot be undone with Ctrl+Z. This sample does not edit cells, but it is designed to raise the error:

Public Sub DemonstrateError400()
    ' The second call conflicts with the open modeless form.
    UserForm1.Show vbModeless
    UserForm1.Show vbModal
End Sub

Other situations worth checking include:

  • A launch button can be clicked again while a modeless form remains open.
  • One procedure opens a form modelessly, while another procedure later opens that same form modally.
  • Code hides a form and then tries to reuse it in a different mode without first unloading it.
  • Several event procedures or forms can reach the same form-opening code, so the form’s state is not what the caller expects.

Not every repeated call to Show produces error 400. Results depend on the form’s current state and how the call is made. If a different error number appears, use that number and its description rather than assuming it is error 400.

How to find the line that raises it

When the message appears during a macro, choose Debug if that option is available. The Visual Basic Editor highlights the statement that failed. On Windows, open the editor with Alt+F11, or use Developer > Visual Basic. In Excel for Mac, use Option+F11 (some keyboards also require Fn) or the Visual Basic command on the Developer tab. Excel for the web does not run VBA macros.

Look for a .Show call and check whether it specifies vbModal or relies on the modal default. Then trace backwards to see whether the same UserForm was previously shown with vbModeless, hidden rather than unloaded, or opened from another event. The highlighted line identifies where VBA detected the conflict, but the earlier call may be the reason the form was already in that state.

You can also inspect the error through VBA’s Err object in an error handler. Capture the number and description before running other statements that could replace the current error information. A simple handler can report what VBA raised:

Public Sub ShowEntryForm()
    Dim errNumber As Long
    Dim errText As String

    On Error GoTo ShowError
    UserForm1.Show vbModal
    Exit Sub

ShowError:
    ' Capture the original error before displaying a message.
    errNumber = Err.Number
    errText = Err.Description
    MsgBox "Error " & errNumber & ": " & errText, vbExclamation
End Sub

This handler reports an error; it does not repair the form’s state. Avoid using On Error Resume Next to hide the problem across a large procedure. Ignoring the failure can make later code behave as though a form opened successfully when it did not.

Ways to fix error 400

Choose one display mode for the form’s current use, or end its existing display before changing modes. If a modeless form is open and you need to reopen it modally, unload that instance first. For a form named UserForm1, a simple launch procedure is:

Public Sub ReopenFormAsModal()
    ' Save a copy of the workbook before running macros.
    If UserForm1.Visible Then
        Unload UserForm1
    End If

    UserForm1.Show vbModal
End Sub

This is intended for a form that is currently modeless or not visible. A modal form normally blocks the user from starting another ordinary macro in that Excel instance until it is dismissed, so the main solution is not to launch it again while it is active. If the form should stay open while the user works in the sheet, use vbModeless consistently instead of trying to make that same open window modal.

There are two different ways to end a form’s display. Hide makes it invisible but keeps the form loaded, including its controls and their current values. Unload closes and releases the loaded form; showing it again creates or loads a form instance anew. If the form contains unsaved input, decide whether to keep or discard that information before unloading it. Do not unload a form automatically just to suppress the error if doing so would lose data the user expects to retain.

For a durable fix, search for every call that opens the form and make their behavior consistent. A single central procedure for launching the form can prevent one button from opening it modelessly while another opens it modally. If repeat launches should be ignored rather than treated as a request to change modes, check whether the form is already visible and bring the user’s attention to the existing window instead of calling Show again.

What error 400 is not

Error 400 in VBA should not be confused with an HTTP 400 “Bad Request” response. HTTP status codes describe a request sent to a web server; VBA error 400 is raised by Office’s macro runtime when it encounters a form-display conflict. The shared number is coincidental and does not mean Excel is sending a web request.

It is also not a worksheet error such as #VALUE!, and it is not a general label for every failed macro. The error’s standard description is specifically about displaying a form modally. If the message instead mentions a missing object, an invalid procedure call, or another problem, diagnose the reported number and description on their own terms.

Frequently Asked Questions

What is the exact meaning of VBA error 400?
Its standard English description is “Form already displayed; can’t show modally.” It indicates that VBA cannot show the form modally in its current display state, commonly because it is already open modelessly.

How do I fix error 400 in Excel VBA?
Close or unload the modeless form before showing it modally, or keep the existing form modeless. Check all procedures that call the form’s Show method so they do not request conflicting display modes.

Does error 400 mean the same thing as HTTP 400?
No. HTTP 400 is a web-server status for a bad request. VBA error 400 is a runtime error about showing a UserForm modally while it is already displayed.

What is the difference between Hide and Unload?
Hide makes a form invisible but keeps it loaded and retains its current control values. Unload closes and releases the loaded form, so it must be loaded again before it is used.

Can I prevent a user from opening the form twice?
Yes. Route form launches through one procedure and check whether the form is already visible. If it is, leave the existing window open or tell the user it is already available rather than issuing another conflicting Show call.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.