Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Tracking Down Invalid References.
by Allen Wyatt
(last updated July 3, 2015)
Joel noted that when he closes a workbook that has thousands of formulas in it he is getting this message lately: "A formula in this worksheet contains one or more invalid references." Joel wonders how he can know which of the seven worksheets in this workbook is being referred to. How can I find the errant formula? I do not observe any problems in the display of information on my reports.
Tracking down invalid references can be frustrating. There are several places you can start to look. The first is in the formulas that are on the worksheets. (Yes, you need to do these steps for each worksheet in the workbook.) Use the Go To Special dialog box (press F5 and choose Special) to choose to go to only the cells that contain errors. You can then use the Tab key to move amongst any cells that Excel selects.
You could also use the Find tool to look for possible errors. Just press Ctrl+F to display the Find tab of the Find and Replace dialog box, then search for the # character. Make sure you tell Excel to do its searching within Formulas. Inspect anything that is found to see if it is an error or not.
You should also take a look at any named ranges defined in your workbook. Look at each name in the Name Manager dialog box (Formulas tab, click the Name Manager tool), making sure that whatever is in the Refers To column doesn't include any error indications.
These aren't all the places that there could be errors; Excel is really good at letting errors exist in lots of places. If you need to search for errors often, you might try a macro that looks through your formulas for any potential errors.
Sub CheckReferences() ' Check for possible missing or erroneous links in ' formulas and list possible errors in a summary sheet Dim iSh As Integer Dim sShName As String Dim sht As Worksheet Dim c, sChar As String Dim rng As Range Dim i As Integer, j As Integer Dim wks As Worksheet Dim sChr As String, addr As String Dim sFormula As String, scVal As String Dim lNewRow As Long Dim vHeaders vHeaders = Array("Sheet Name", "Cell", "Cell Value", "Formula") 'check if 'Summary' worksheet is in workbook 'and if so, delete it With Application .ScreenUpdating = False .DisplayAlerts = False .Calculation = xlCalculationManual End With For i = 1 To Worksheets.Count If Worksheets(i).Name = "Summary" Then Worksheets(i).Delete End If Next i iSh = Worksheets.Count 'create a new summary sheet Sheets.Add After:=Sheets(iSh) Sheets(Sheets.Count).Name = "Summary" With Sheets("Summary") Range("A1:D1") = vHeaders End With lNewRow = 2 ' this will not work if the sheet is protected, ' assume that sheet should not be changed; so ignore it On Error Resume Next For i = 1 To iSh sShName = Worksheets(i).Name Application.Goto Sheets(sShName).Cells(1, 1) Set rng = Cells.SpecialCells(xlCellTypeFormulas, 23) For Each c In rng addr = c.Address sFormula = c.Formula scVal = c.Text For j = 1 To Len(c.Formula) sChr = Mid(c.Formula, j, 1) If sChr = "[" Or sChr = "!" Or _ IsError(c) Then 'write values to summary sheet With Sheets("Summary") .Cells(lNewRow, 1) = sShName .Cells(lNewRow, 2) = addr .Cells(lNewRow, 3) = scVal .Cells(lNewRow, 4) = "'" & sFormula End With lNewRow = lNewRow + 1 Exit For End If Next j Next c Next i ' housekeeping With Application .ScreenUpdating = True .DisplayAlerts = True .Calculation = xlCalculationAutomatic End With ' tidy up Sheets("Summary").Select Columns("A:D").EntireColumn.AutoFit Range("A1:D1").Font.Bold = True Range("A2").Select End Sub
This macro creates a worksheet called "Summary" that is used to list information about any errors detected in the worksheet links.
You can also use Excel MVP Bill Manville's FindLink program, which does an amazing job of locating information in links. You could use the add-in to search for the # character in all your links, which should help you locate the errors. It is unclear as to whether the add-in will work with Excel 2013, as the last update for the file (as of this writing) was in 2011. It is worth trying though; more information on FindLink can be found here:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (8664) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Tracking Down Invalid References.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Want to add up a bunch of scores, without including the lowest one in the bunch? You can make a small change to your formula ...Discover More
You could use Excel to collect data that is useful in your business. For instance, you might use it to collect information ...Discover More
Addresses used in a formula can be either relative or absolute. If you need to switch between the two types of addressing, ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.