The "VBA Runtime Error 360" typically occurs when a macro or code references an object—such as a worksheet or chart—before it has been properly loaded, or when an object is already loaded elsewhere in the code. This error prevents your Excel VBA script from running as expected, often during initialization or when opening multiple objects simultaneously. Since this is a common issue, you can resolve it by ensuring proper object initialization and loading order in your macros.

What You'll Need

  • Access to Excel with VBA editor enabled (File > Options > Advanced > Enable all Excel events)
  • Basic familiarity with Excel and VBA syntax
  • A clean copy of your workbook with the problematic macro
  • Optional: Debugger knowledge (F8 to step through code)

Step-by-Step Fixes

  1. Check the Object Reference: Open the VBA editor (Alt+F11), select the module with the error, and review all object references (e.g., `Worksheets("Sheet1")`, `Charts(1)`). Verify that: - The object names match exactly (case-sensitive in VBA). - The object exists in the workbook (e.g., `Worksheets("Sheet1")` should match an actual sheet name). - No typos exist in the code line generating the error.
  • Load Objects in the Correct Order: If multiple objects are accessed in sequence, ensure the most specific object (e.g., `Worksheets("Sheet1")`) is initialized before more generic ones (e.g., `Workbooks("Test.xlsm").Worksheets`). For example:
        Dim ws As Worksheet
        Set ws = ThisWorkbook.Worksheets("Sheet1") ' Specific sheet first
        Sheets(ws.Name).Range("A1").Value = "Data"
        
    If that did not work Move all object references inside a procedure (e.g., `Sub Main()`) to avoid global conflicts.
  • Use Late Binding for Uncertain Objects: Replace strict typing (`Dim ws As Worksheet`) with late binding to avoid errors if the object fails to load:
        Dim ws As Object
        On Error Resume Next
        Set ws = ThisWorkbook.Worksheets("Sheet1")
        On Error GoTo 0
        If ws Is Nothing Then Exit Sub ' Exit if object not found
        ws.Range("A1").Value = "Data"
        
    Caution: Late binding is slower; use only when the object’s existence is uncertain.
  • Enable Error Handling in Code: Add error handling blocks to catch and log the issue:
        On Error GoTo ErrorHandler
        ' Your code here
        Exit Sub
        ErrorHandler:
        MsgBox "Error " & Err.Number & ": " & Err.Description
        End Sub
        
    This highlights where the error occurs and prevents freezing.
  • Close and Reopen the Workbook: Sometimes, corrupt object references cause this error. Save your workbook, close it, and reopen it. If the error persists, check for: - Macros with undefined objects (e.g., `Worksheets("Nonexistent")`). - Circular references between worksheets or charts.
  • Reset VBA References (Advanced): If the issue is persistent, reset Excel’s VBA references: 1. In the VBA editor, go to Tools > References. 2. Uncheck any unrecognized or outdated references (e.g., "Microsoft Excel Objects 16.0"). 3. Restart Excel and test the macro again. Note: This won’t delete your code but ensures references are clean.
  • Common Mistakes

    • Assuming Objects Exist: Code like `Sheets("Sheet1").Range("A1").Value = "x"` will fail if "Sheet1" doesn’t exist. Always validate object existence with error handling or explicit checks.
    • Overloading Objects Globally: Naming variables after objects (e.g., `Dim Worksheet1 As Worksheet`) conflicts with Excel’s internal objects (e.g., `ThisWorkbook.Worksheets("Sheet1")`). Avoid shadowing built-in names.
    • Ignoring Case Sensitivity: VBA treats "worksheet" and "Worksheet" as different. Use consistent casing in object names.
    • Modifying Objects in Loops Without Checks: Iterating over worksheets or charts without error handling can trigger this error if the collection is empty or corrupt.
    • Skipping Workbook Initialization: Macros like `Dim wb As Workbook` without initializing it (`Set wb = ThisWorkbook`) will fail when referencing `wb.Worksheets`. Always assign the workbook first.

    Tips

    • Use Debug.Print for Validation: Add `Debug.Print "Sheet1 exists: " & IsObject(ThisWorkbook.Worksheets("Sheet1"))` to test object existence before using it.
    • Check for Hidden Worksheets: Hidden sheets (`Worksheets("Sheet1").Visible = xlSheetVeryHidden`) may not load immediately. Explicitly set visibility or use late binding to avoid errors.
    • Test in a New Workbook: Duplicate the problematic macro into a fresh workbook to rule out workbook-level corruption (e.g., saved macros, add-ins).
    • Review Third-Party Libraries: If your macro uses external VBA libraries (e.g., from add-ins), ensure they’re properly referenced and loaded before use.
    • Avoid Dynamic Ranges Without Validation: Code like `Sheets(1).Range("A1:Z100")` assumes 100 columns exist. Use `Application.UsedRange` or explicit ranges with error handling.

    Troubleshooting

    1. If the Error Persists After Steps 1–5: - Clear the VBA editor’s cache: Close Excel, delete the VBA project’s `.vbp` file (located in Excel’s installation folder), and restart Excel. - Check for macro add-ins: Disable add-ins by opening VBA > Tools > References and unchecking suspicious entries. Test the macro again.
    2. If You See "Object Not Set" Errors: The issue is likely a loose object reference (e.g., `ws.Range("A1")` where `ws` is undefined). Reassign `Set ws = ThisWorkbook.Worksheets("Sheet1")` before using it.
    3. If the Error Occurs Only in Specific Scenarios: - Replicate the scenario (e.g., opening multiple files in a loop) in a debugged macro to isolate the problematic line. - Enable Excel’s Visual Basic Debugger (F8) and step through code to see where the object fails to load.
    4. If the Workbook is Corrupt: Save the workbook as a new file (File > Save As > Choose a format like `.xlsx`), then reimport macros. This avoids loading corrupted references.

    Frequently Asked Questions

    Why does my VBA macro fail with "Object Already Loaded" when it worked before?

    This error often occurs due to: - A change in workbook structure (e.g., renaming a sheet or adding a hidden sheet). - A recent Excel update breaking object references. - A corrupt macro project (e.g., macros not saving properly during updates). Solution: Restart Excel, reset VBA references, or test in a fresh workbook.

    Can I fix this error without debugging my entire macro?

    Yes. Use late binding (as shown in Step 3) or error handling (Step 4) to bypass the issue without rewriting the entire macro. This lets you identify the problematic line later.

    Does this error apply to other Office programs (Word, PowerPoint)?

    The exact error code may vary, but similar issues arise in Word (e.g., "Object Not Set") or PowerPoint when referencing objects (e.g., `ActiveChart`) before they’re loaded. Always validate object existence with error handling.

    Why does my code work in one workbook but not another?

    This usually happens because: - The second workbook has different sheet names or structures. - Macros were added/edited differently (e.g., copied/pasted vs. direct editing). - The second workbook has add-ins or unused references that conflict with the first. Test each workbook in isolation or compare sheet names/object references.

    How do I prevent "Object Already Loaded" errors in the future?

    Adopt these habits: - Always initialize objects before using them (e.g., `Set ws = ThisWorkbook.Worksheets("Sheet1")`). - Use late binding for dynamic objects (e.g., when sheet names are input by the user). - Validate object existence with `IsObject()` or error handling. - Avoid global variables named after built-in objects (e.g., `Dim Worksheet1` conflicts with `ThisWorkbook.Worksheets("Sheet1")`).

    What if I’m using Excel Add-ins (like Power Query)?

    Add-ins can load objects asynchronously, causing timing issues. To prevent errors: - Load add-ins programmatically with `Application.AddIns.AddByPath` before running macros. - Use late binding or `On Error Resume Next` to handle loading delays. - Test macros in Add-in settings > "Use Application Events" mode to simulate loading.