The VBA error “Can’t find project or library” usually means the workbook’s VBA project has a broken reference to a library that is missing or unavailable on your computer. In Excel for Microsoft 365 on Windows, open the Visual Basic Editor, choose Tools > References, clear the check box beside any entry marked MISSING, then compile the project and restore that library if the code needs it.
What the error means
A VBA project can use code and features supplied by other components, called references or libraries. For example, a project might refer to the Excel object library, the Microsoft Scripting Runtime, or a library installed by another application. The reference tells VBA where to find the names, objects, and definitions that the code expects.
If VBA cannot locate a referenced library, it may stop compiling with “Can’t find project or library.” This is generally a dependency problem, not evidence that the workbook itself is corrupt. The affected reference might be absent, have moved, be unregistered, or be incompatible with the current computer or Office installation. A file that worked on one computer can therefore fail on another if the second computer does not have the same dependency.
The wording can be confusing because the missing item may be a library rather than another workbook or a VBA project file. The References dialog is the best first place to identify what VBA is looking for. Avoid changing unrelated settings or reinstalling Office before checking it.
Find and clear a missing reference
- Open the workbook in the Excel desktop app and make a copy before making changes. A macro can change workbook content, and its actions usually cannot be reversed with Ctrl+Z.
- Press Alt+F11 in Excel for Windows to open the Visual Basic Editor. You can also use the Developer tab and choose Visual Basic if that tab is available.
- In the editor, select the affected workbook or VBA project in Project Explorer. If Project Explorer is hidden, press Ctrl+R.
- Choose Tools > References. Look through the list for an item prefixed with MISSING:.
- If the missing library is not required, clear its check box. Do not clear other references simply to experiment; the project may rely on them.
- Choose OK, then use Debug > Compile VBAProject, or the corresponding Compile command showing the project name. If compilation succeeds, save the workbook and check the relevant macro.
Compilation can reveal another missing item or a separate code problem. If the missing reference is required, clearing it may only move the failure to a later compile error or runtime error. In that case, identify and restore the correct library rather than treating the checkbox change as a complete repair.
On a Mac, open the workbook in desktop Excel and use the Visual Basic Editor’s Tools > References menu; keyboard shortcuts can vary with the keyboard and macOS function-key settings. Excel for the web does not run VBA macros or provide the desktop Visual Basic Editor, so open the file in desktop Excel to inspect references.
Decide whether to remove or restore it
A MISSING entry does not by itself tell you whether the dependency is optional. The code may use it directly, or the reference may have been added accidentally or left behind after a component was removed. Before changing it, note the full name of the missing item and consider how the workbook is used.
- Remove the reference if the workbook no longer needs that library and the project compiles and works without it. Test the workbook’s important macros and features, not only the one that first displayed the error.
- Restore the dependency if the project uses objects, methods, or constants from it. Install or repair the software that supplies the library, or obtain the correct component from the workbook’s owner or your organization’s IT team.
- Replace the dependency in code if the workbook must work across computers where that library cannot be guaranteed. This requires changing and testing the code; it is not always a safe one-click fix.
Some references are fundamental to the project or supplied by Office, and should not be removed casually. If the workbook is business-critical, shared, or protected, ask its maintainer before changing its references. Keep the original file so you can compare or restore it if the project stops working.
Why a reference goes missing
The most common cause is a difference between the computer where the workbook was created and the computer where it is opened. A library may be installed on the first machine but absent from the second. This often happens with optional Office components, third-party applications, or libraries that a developer added for a specific task.
Other causes include upgrading or reinstalling software, moving to a new computer, removing an application, or opening the workbook in an environment with a different set of installed components. A reference can also be unavailable because the relevant file is damaged or its registration is broken. In managed workplaces, installation restrictions can prevent a user from restoring it themselves.
Architecture and platform differences can matter too. A component designed for Windows may not be available on Mac, and older ActiveX or COM dependencies are not generally portable to Mac or Excel for the web. Office bitness can also affect certain external components. Do not assume that changing between 32-bit and 64-bit Office is the first or only solution: first identify the library and check its documented compatibility.
Why ordinary VBA functions may appear to fail
A missing reference can make the error appear on a line that uses a familiar VBA function, even when that line looks correct. VBA resolves names while compiling the project, and an unresolved library can disrupt that process. The highlighted word may be a symptom rather than the source of the problem.
For example, if the editor highlights a built-in name such as Date, Left, or a common data type, do not immediately rewrite that expression or conclude that the function has disappeared from VBA. Check Tools > References first. Once the missing reference is resolved, the apparent error on that line may go away. If compilation still fails, then investigate the specific highlighted code and any additional compile message.
This is also why fixing only the macro that produced the message may not work. A VBA project can contain multiple modules, forms, and procedures that rely on the same reference. Compile the project after addressing the dependency, and then test the relevant workflows.
Restoring a required library safely
If the code depends on the missing library, use its name in the References dialog to determine what supplies it. Check the workbook’s documentation or ask the person who created it. If it belongs to an installed application, use that application’s official installer or repair option, following your organization’s IT process where applicable.
The References dialog may offer a Browse button for locating a library file. Use it only when you know the exact, legitimate file and version that the project expects. A library file might have an extension such as .olb, .tlb, .dll, or .ocx, but selecting an arbitrary file with one of those extensions will not necessarily create a valid reference. Do not download DLL or OCX files from unverified websites, and do not make registry changes based on generic instructions. Incorrect components can create security and stability risks.
After restoring a dependency, reopen Tools > References and confirm that the entry is no longer marked MISSING. Compile the project and test the macros that use it. If the reference remains unavailable, the component may be the wrong version, not registered correctly, incompatible with the system, or blocked by installation policy. At that point, the component’s vendor or your IT team is a better source of help than repeated changes to the workbook.
References, early binding, and portability
With an early-bound reference, VBA knows about a library’s object types and constants while the project is being compiled. This can make code easier to browse and can provide editor assistance, but the required library must be available to each user. For instance, a workbook that uses objects from a separately installed application may not compile on a computer without that application or compatible library.
Late binding is one possible design alternative for some automation tasks. Instead of requiring a specific library reference at compile time, code can create an object at runtime using a programmatic identifier. This can reduce reference-related problems when supporting multiple compatible versions, but it does not make an unavailable application appear on the computer. It can also remove compile-time help and require different handling for constants and errors. Converting a project to late binding is a code change that should be designed and tested, not an automatic repair for every missing reference.
For workbooks distributed to a team, document nonstandard dependencies and confirm that recipients can install them. If the workbook has to run on Windows and Mac, avoid assuming that Windows-only components will be available everywhere. A simpler design with fewer external dependencies is often easier to maintain.
Other causes to check after References
If no entry is marked MISSING, or clearing an optional missing reference does not solve the problem, use the exact error and the highlighted code to narrow down the cause. A different compile error can be mistaken for the same issue, especially if it appears after the first problem is fixed.
- Check the selected project. A workbook may contain more than one VBA project, such as an add-in or another open workbook. Make sure Tools > References is showing the project that produced the error.
- Compile again and read the next message. Debug > Compile VBAProject can expose a separate unresolved name, syntax error, or other issue after a missing reference is removed.
- Check compatibility. Confirm whether the library supports the installed operating system and Office architecture, especially for third-party or legacy components.
- Separate security from dependency errors. Macro security settings affect whether code can run, but they do not ordinarily repair a broken library reference. Enable macros only for files you trust and in accordance with your organization’s policy.
- Ask for the original dependency details. For a workbook received from someone else, ask which software or library it requires and which versions are supported.
If the VBA project is password-protected or controlled by an organization, do not try to bypass that protection. Ask the owner or administrator to update the project or provide a supported version. If the error persists in multiple workbooks that use standard Office libraries, repair Office through Windows’ installed-app settings or seek Microsoft support; for one workbook with a named third-party dependency, contact that component’s supplier first.
Frequently Asked Questions
Can I fix “Can’t find project or library” by unchecking MISSING?
Only if the project does not need that library. Clear the missing reference, compile the project, and test its relevant macros. If the code depends on the library, restore it or have the code updated instead.
Why does VBA highlight Left, Date, or another built-in function?
A broken reference can interfere with compiling names across the project, so the highlighted built-in function may not be the real cause. Check Tools > References for an entry marked MISSING before editing that line.
Will removing a reference delete my macros?
Clearing a reference does not normally delete macro code, but code that depends on that library may stop compiling or working. Make a copy first and test the project after the change.
Does this error mean macros are disabled?
Not usually. Macro security controls whether VBA code is allowed to run; a missing reference means the project cannot locate a dependency. Treat the two issues separately and do not lower security settings to try to fix a library reference.
Can Excel for the web fix this error?
No. Excel for the web does not run VBA or provide the desktop VBA editor’s References dialog. Open the workbook in desktop Excel to inspect and repair its VBA references.
Related
- Microsoft Excel: How to Change the Print Area
- Merge Cells but Keep All Text in Excel: Safe Methods
- Microsoft Excel Always Not Responding? Causes and Fixes
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA Insert Row Below Active Cell: Code and TipsTo insert a complete worksheet row immediately below the active cell in Excel for Microsoft 365 on Windows,…
- Excel VBA Date to Number: Convert Dates to SerialsIn Excel VBA, convert a Date value to a number with CDbl(dateValue). The result is a serial value:…
- Excel VBA: Turn On AutoFilter and Show Filter ArrowsTo turn on AutoFilter in Excel VBA, call the AutoFilter method on the complete data range, including its…
- VBA Loop Count: Limits, Counter Types, and RuntimeVBA has no single built-in maximum number of loop iterations. A loop can keep running as long as…
- Excel VBA Open Workbook Dialog: A Practical How-ToTo display a workbook picker in Excel VBA, call Application.GetOpenFilename, check whether the user cancelled, and pass the…
- VBA Find a Character in a StringIn VBA, use the InStr function to find a character in a string: it returns the character’s position,…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.