Excel VBA AI Assistant LogoExcel VBA AI Assistant
    Debugging
    VBA
    Troubleshooting
    Error Handling
    Featured

    The Most Common VBA Runtime Errors – Causes & Solutions

    A field guide to common VBA runtime errors (9, 91, 13, 1004) and how to resolve them.

    VBA AI Team
    Published on August 17, 2025
    12 min read

    The Most Common VBA Runtime Errors – Causes & Solutions

    A quick reference for errors you’ll see often—and how to fix them.


    9: Subscript out of range

    • Wrong sheet/workbook/index.
    Set ws = ThisWorkbook.Worksheets("Data") ' not ActiveWorkbook
    • Using Cells(row, "col") with invalid indexes.

    91: Object variable not set

    • You used a variable like ws before Set ws = ... succeeded.
    • Validate existence:
    If Evaluate("ISREF('Data'!A1)") Then Set ws = Worksheets("Data")

    13: Type mismatch

    • Assigning text to numeric or using Variant unpredictably.
    • Coerce types or validate with IsNumeric, CLng, CDbl.

    1004: Application-defined or object-defined error

    • Invalid range operations, protected sheets, filtered ranges.
    • Use SpecialCells(xlCellTypeVisible) for filtered ranges.

    Work faster with the VBA Assistant

    Create, explain, and improve your VBA code with examples, comments, and best practices—directly in your workflow.