Error running VBA code: User Interrupt

Last Published: April 25, 2020

Error Message

The following error occurs when using the Field Calculator:

"Error running VBA code: User Interrupt"


There is a syntax error in the VBA code.

Solution or Workaround

The procedure below is for ArcGIS 9.3.1 or earlier versions. Starting at ArcGIS 10.0, expressions in the Calculator are created using only VBScript or a standard Python format.

Examine the code for the syntax error. To find the error, compile the code in the VBA editor provided with ArcMap.

  1. With the Field Calculator dialog box open, use the mouse to select the code. Right-click and select 'Copy.'
    [O-Image] Field Calculator - Copy code
  2. Click 'Cancel' to close the Field Calculator dialog box.
  3. Select 'Tools > Macros' to create a new VBA macro.
  4. Type a name for the macro in the Macros dialog box; for example 'Test'. Make sure to create the macro in the document. Click 'Create.'
  5. There should now be an empty subroutine in the VBA editor that can be used to test the code's syntax. Right-click inside the subroutine and select 'Paste' to paste the code copied from the Field Calculator in Step 1. The code should look similar to this:

    Sub test()
    Dim x As String
    x = ucased([NAME_FIELD])
    End Sub

  6. Test the code in this environment. Change the field parameter to a hard-coded string.

    Sub test()
    Dim x As String
    x = ucased("Ziggy Stardust")
    End Sub

  7. Add a line of code to call up a message box with the output of the code for this test string.

    Sub test()
    Dim x As String
    x = ucased("Ziggy Stardust")
    MsgBox x
    End Sub

  8. Select 'Tools > Macros' and click 'Run' to run the macro and check for proper syntax.
  9. If the macro has any syntax errors, a VBA error will be generated. In this example, the error is that the proper name for the uppercase function is not being used. The proper name for this function is 'UCase' and not 'ucased'.
    [O-Image] VBA Error
  10. Modify the code to correct the syntax error. Run the macro again.
    [O-Image] Ziggy Stardust Message Box
  11. Using copy/paste, return to ArcMap, open the Field Calculator, and correct the syntax there.
  12. Click OK on the Field Calculator dialog box to execute the calculation.

Article ID:000002953

  • ArcMap 9 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options