If Excel VBA says “Can’t find project or library,” the VBA project usually has a reference to a library that is missing, unregistered, or incompatible on your computer. In the Visual Basic Editor, open Tools > References, look for an entry marked MISSING, then clear it or replace it with the correct available library; compile the project afterward to check whether the code still needs that dependency.
What the error means
VBA projects can refer to libraries that provide extra functions, object types, constants, and methods. Excel includes some references by default, such as the Excel Object Library and the Visual Basic for Applications library. A project may also rely on another Office application, a Windows component, a third-party program, or a library installed separately.
When VBA cannot resolve a required reference, it may stop during compilation with “Can’t find project or library.” This is generally a compile-time problem, not a worksheet formula error and not necessarily a sign that the workbook itself is damaged. The project may fail before a macro runs, even if the procedure you intended to run does not appear to use the missing library directly.
References can also affect how VBA interprets names in code. If a library defining a data type is unavailable, for example, a declaration using that type may no longer compile. Other code may depend on functions or constants supplied by the same library. Fixing the reference is therefore different from simply dismissing the error: the project may need a compatible replacement or a code change.
Why a reference goes missing
A workbook stores information about the libraries its VBA project expects to find. It does not necessarily contain those libraries. If the workbook moves to a different computer, Windows installation, or Office setup, VBA may not be able to locate one of them.
- A required component is not installed. A macro might use a library supplied by an application or vendor product that is absent on the current computer.
- The library was removed or changed. Uninstalling software, updating it, or changing its installation location can leave an old reference unresolved.
- The project was created on another setup. A reference available to the workbook’s author may not exist on a colleague’s machine, or may have a different version.
- A Windows component is not registered correctly. Some libraries must be registered with Windows so applications can locate them. A damaged installation can disrupt that registration.
- The project uses a platform-specific dependency. A Windows COM component, for example, may not be available in Excel for Mac.
Common examples include references to the Microsoft Scripting Runtime, an Outlook or other Office Object Library, an ActiveX Data Objects library, and vendor-provided components. These examples are not automatically errors: they are valid when the project needs them and the appropriate library is installed and available.
Find the broken reference in Excel for Windows
Use the desktop version of Excel for Microsoft 365 on Windows. Save a copy of the workbook first, especially if you are changing a shared or important VBA project. If the Developer tab is available, select Developer > Visual Basic. Otherwise, press Alt+F11 to open the Visual Basic Editor. In Excel for Mac, Option+F11 opens the editor on many keyboards; you may need to press Fn as well, depending on the keyboard settings.
- In the Visual Basic Editor, select the affected workbook or VBA project in Project Explorer. If Project Explorer is hidden, press Ctrl+R on Windows.
- Select Tools > References. The References dialog lists the libraries the project can use.
- Look for an entry that begins with MISSING: or otherwise indicates that the reference is unavailable. Note its name before changing anything.
- Close the dialog after making a note of the entry, or leave it open while you check whether the library is actually needed.
A missing item is strong evidence, but do not clear every unfamiliar reference indiscriminately. The project may depend on it for declared types, constants, or object methods. If you are not the workbook’s author, ask the owner what software or component the project requires. A reference name can identify the dependency more clearly than the error message alone.
If the References dialog contains no visibly missing entry, the problem may be more involved: the project could be using an unavailable component in another referenced project, or the installation may have a registration issue. Record the exact error and the reference list before proceeding. This makes it easier for the workbook’s author or an IT administrator to identify what is expected.
Clear or replace the reference safely
If you confirm that a missing library is not used by the project, clear its checkbox in Tools > References and select OK. Then, in the Visual Basic Editor, select Debug > Compile VBAProject. If compilation succeeds, save the workbook and test its relevant macros using a copy of the data. If the project now reports another error, that is useful information: the missing library may have been masking a separate issue.
If compilation reports a type, method, or constant that is not defined, the project probably does need the library or an equivalent. Restore the correct component if possible, or ask the developer to update the code. A replacement reference should be the intended library and a compatible version—not merely another item with a similar name. Different versions can expose different features or behave differently.
Use a library’s installer or the software vendor’s supported repair process to restore a required component. Avoid downloading an unfamiliar DLL or copying a library file from another computer. A library can depend on other files and Windows registration, and an untrusted file is also a security risk. If the missing reference is a standard Office library across multiple workbooks, repair or update Microsoft 365 through your organization’s approved process rather than editing system files by hand.
After changing references, test the actual workflows that use the workbook. A successful compile confirms that VBA can resolve names at compile time; it does not prove that a required application is installed, that a connection will work, or that every macro behaves correctly at run time.
When the project really needs the library
Some references are essential. A project that declares a variable using a type from a library, calls a method defined by it, or uses its constants may stop compiling when that reference is removed. In that situation, unchecking the item is not a complete repair. The right fix is usually to install or repair the dependency, or to have the code revised to use an available alternative.
For example, a macro that automates Outlook may refer directly to Outlook-specific object types. That can require a compatible Outlook Object Library on the computer where the project is compiled. A developer can sometimes redesign automation to use late binding, which reduces the need for a compile-time reference to a particular application library. However, this is a code change, not a checkbox fix. Declarations, constants, error handling, and features that depend on early-bound types may need adjustment, and late binding is not suitable for every dependency.
If the workbook is distributed to other people, ask the developer to document required applications and library versions. A workbook that works only on its author’s computer is not necessarily portable. Sharing the dependency information with recipients or IT support can prevent repeated trial-and-error changes.
Office versions, 32-bit and 64-bit differences
A library can be present but still not work in a particular Office setup. One important distinction is whether Office is 32-bit or 64-bit. Some in-process COM components are built for one architecture and cannot be loaded by Office of the other architecture. This is especially relevant to older vendor add-ins and controls. Check the Office installation’s architecture and the component vendor’s compatibility information before reinstalling or changing code.
Architecture differences can also lead to other VBA compile errors, particularly in older code that declares Windows API calls. Those errors are related to compatibility but are not identical to “Can’t find project or library.” Do not assume that changing a reference will fix every compile problem on a 64-bit installation. The project may need a developer to update its declarations or replace an incompatible component.
Office updates can expose version assumptions too. A workbook created with a newer or additional component may not compile on a computer without it. Conversely, selecting a different library version without checking the code can introduce incompatibilities. Keep a copy of the original workbook and note the exact library name and version when asking for support.
Errors that are easy to confuse with this one
Several VBA messages can appear during the same troubleshooting session but point to different problems. “User-defined type not defined” often means that VBA cannot resolve a type declaration, which can result from a missing reference. It can also indicate a spelling mistake or an undeclared type that the project author needs to fix. The highlighted line and the References list help distinguish these cases.
A run-time error occurs after code begins executing, whereas “Can’t find project or library” is commonly encountered while VBA is compiling or resolving the project. Macro security settings, such as blocking macros from an untrusted file, can prevent code from running, but changing security settings does not restore a missing library. Likewise, reinstalling Excel is not the first step when a single project has an obvious missing third-party reference.
If the error persists after correcting the reference, select Debug > Compile VBAProject and read the next message carefully. Record the procedure or line highlighted, the workbook’s origin, the Office version and bitness, and the names of any missing references. That information helps separate a dependency problem from a code defect, a damaged installation, or a security restriction.
Mac and Excel for the web
Excel for Mac supports VBA, but it does not provide the same Windows environment. A project that depends on Windows-only COM libraries, ActiveX controls, or Windows API calls may not work on a Mac even if its workbook opens. Check whether the workbook’s author provides a Mac-compatible version. Removing a Windows reference can make a project compile only if the code no longer requires the associated feature.
Excel for the web can open workbooks that contain macros, but it cannot create, edit, or run VBA macros. Use desktop Excel for VBA troubleshooting. If you only have access to the web version, ask someone with the appropriate desktop version to inspect the project, or use a non-VBA workflow if one is available.
Prevent the error when sharing workbooks
Before distributing a macro-enabled workbook, identify external dependencies and test it on a computer that does not have the author’s full development setup. State which Office applications, add-ins, vendor components, or library versions are required. Where practical, avoid unnecessary references and use features available to all intended users.
For a workbook used within an organization, ask IT to package and maintain required components rather than having each user install files manually. If recipients use different platforms, test the project on each supported platform and clearly state any limitations. Keep an unchanged backup before editing references, and retain a version of the workbook that is known to work. These steps do not prevent every compatibility issue, but they make the cause easier to identify and recovery safer.
Frequently Asked Questions
Can I fix “Can’t find project or library” by unchecking MISSING?
Only if the project no longer needs that library. Clear the reference, compile the project, and test the macros. If VBA then reports undefined types or members, restore the dependency or have the code updated.
Why does the error appear when I run a different macro?
VBA may need to resolve references across the project before it can compile the procedure you chose. The missing library can therefore block a macro even when the visible procedure does not obviously use it.
Will enabling macros fix the error?
No. Macro permissions control whether code can run; they do not install or reconnect a missing library. Resolve the reference separately, and follow your organization’s security rules when opening macro-enabled files.
Can Excel for the web repair a VBA reference?
No. Excel for the web does not provide the VBA editor or run VBA macros. Open the workbook in desktop Excel on a compatible computer to inspect and repair the project.
Should I remove every reference I do not recognize?
No. An unfamiliar library may supply types, constants, or methods the project needs. Identify its purpose first, keep a backup, and consult the workbook’s author or IT support if its role is unclear.
Related
- Excel Page Break Dotted Lines: How to Move Them in Print
- Excel Merge Cells and Keep All Text Without Data Loss
- Excel Merged Cells: Do They Need to Be the Same Size?
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA: Set the Active Workbook as a VariableIn Excel VBA, declare a variable as a Workbook and assign the active workbook with Set wb =…
- Read a Text File with Excel VBA: Methods and ExamplesYes. In Excel for Microsoft 365 on Windows, VBA can read a plain-text file with the Open and…
- Call a Macro from an Excel UserForm ButtonYes. In Excel for Microsoft 365 on Windows, put a call to a Public Sub in the UserForm…
- VBA Active Worksheet: How to Reference the Current SheetIn Excel VBA, use ActiveSheet to refer to the sheet that is currently active in the Excel window.…
- Excel Macros in Google Sheets: What Works?No: Google Sheets cannot run Excel VBA macros, even when you open an Excel workbook that contains them.…
- Excel VBA Visible Worksheet Property: How to Set ItIn Excel VBA, a worksheet’s visibility is controlled by its Visible property. Set it to xlSheetVisible to show…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.