← All Excel VBA Flashcard Decks

Excel VBA Error Handling & Debugging Flashcards

21 cards from real Excel VBA practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 20 Excel VBA Error Handling & Debugging flashcards as text
  1. Which statement is used to enable error handling and redirect execution to a labeled section in Excel VBA?

    Answer: On Error GoTo

    'On Error GoTo' is the VBA statement that redirects execution to a specified error handler label when a runtime error occurs.

  2. What does 'On Error Resume Next' do in VBA?

    Answer: Allows execution to continue with the statement following the error

    'On Error Resume Next' instructs VBA to continue executing with the statement immediately following the one that caused the error.

  3. Which built-in VBA object is used to retrieve information about the most recently occurring error?

    Answer: Err

    The 'Err' object contains properties like Number, Description, and Source that provide details about the last error that occurred.

  4. What is the purpose of the Err.Clear method in VBA?

    Answer: Resets the Err object's properties to their default zero/empty values

    Err.Clear resets the Err object's Number, Description, and Source properties to their default values (0 and empty strings).

  5. In VBA, what happens if a runtime error occurs inside an active error handler?

    Answer: The current error handler is disabled and the error propagates to the caller

    If an error occurs within an error handler, VBA disables that handler and passes the error up to the calling procedure's error handler.

  6. Which keyword is used at the end of an error handler to return execution to the main code flow?

    Answer: Resume

    The 'Resume' keyword directs execution back to the main code — either re-trying the error line, moving to the next line, or jumping to a specified label.

  7. What does 'Resume Next' do when placed inside a VBA error handler?

    Answer: Continues execution with the statement after the one that caused the error

    'Resume Next' directs VBA to continue execution with the statement immediately following the line that caused the error, effectively skipping it.

  8. Which VBA debugging action executes code one line at a time, including stepping into called procedures?

    Answer: Step Into

    'Step Into' (F8) executes code one line at a time and enters any called Sub or Function to debug it line by line.

  9. What is a breakpoint in the context of VBA debugging?

    Answer: A marker that pauses execution when that line is reached

    A breakpoint is a marker set on a specific line that causes VBA to pause execution when reached, allowing inspection of variables and program state.

  10. Which window in the VBA IDE allows you to type and execute VBA statements interactively without running a full procedure?

    Answer: Immediate Window

    The Immediate Window (Ctrl+G) lets developers type and run VBA expressions instantly, making it ideal for testing snippets and inspecting values.

  11. What information does the Locals Window display during VBA debugging?

    Answer: All variables in the current procedure scope with their current values and types

    The Locals Window automatically displays all variables in the currently executing procedure's scope, showing their names, types, and current values.

  12. Which VBA debugging feature lets you monitor a specific variable or expression and optionally pause execution when its value changes?

    Answer: Watch Expressions

    Watch Expressions (added via Debug > Add Watch) monitor specific variables or expressions and can pause execution when the watched value changes or meets a condition.

  13. What is the key difference between 'Step Into' (F8) and 'Step Over' (Shift+F8) during VBA debugging?

    Answer: Step Into enters called procedures line by line; Step Over executes them as a single step

    'Step Into' descends into any called Sub or Function to debug it, while 'Step Over' executes the called procedure entirely without entering it.

  14. Which VBA statement outputs values and messages to the Immediate Window during code execution for logging purposes?

    Answer: Debug.Print

    'Debug.Print' writes values or messages to the Immediate Window at runtime, which is useful for tracing variable values without stopping execution.

  15. What is the effect of using 'On Error GoTo 0' in a VBA procedure?

    Answer: Disables any currently active error handler in the procedure

    'On Error GoTo 0' disables the currently active error handler, causing VBA to revert to its default unhandled-error behavior for any subsequent errors.

  16. What does the Err.Number property return when no error has occurred in VBA?

    Answer: 0

    When no error has occurred, Err.Number returns 0, which is why 'If Err.Number <> 0' is the standard pattern for detecting whether an error happened.

  17. Which error handling approach is most appropriate for production VBA code that needs to respond differently to multiple error types?

    Answer: Use a GoTo handler with a Select Case block on Err.Number

    A GoTo error handler with a Select Case on Err.Number lets you apply specific logic per error type, resulting in robust and maintainable error handling.

  18. What is 'error propagation' in VBA?

    Answer: An unhandled error bubbling up the call stack to the calling procedure

    Error propagation occurs when a procedure has no error handler (or re-raises the error), causing the error to move up the call stack to the calling procedure.

  19. What is the correct syntax to raise a custom user-defined error in VBA?

    Answer: Err.Raise Number, Source, Description

    Err.Raise allows you to generate a custom error by specifying an error number, source, and description, enabling custom error signaling within procedures.

  20. Which range of error numbers is reserved for user-defined errors raised with Err.Raise in VBA?

    Answer: 512 to 65535

    VBA reserves error numbers 512 through 65535 for user-defined errors; numbers below 512 are reserved for VBA's built-in runtime errors.

How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Not reviewed by a subject-matter expert. Editorial policy