In this tutorial, I will explain the details of reference (#REF!) errors and guide you on how to find the errors in excel. Besides, I will mention possible reasons for this error. For your better understanding, I will briefly discuss how you can prevent and fix the reference (#REF!) errors.
Download Practice Workbook
You can download the practice workbook that we have used to prepare this article.
What is Reference (#REF!) Error in Excel?
Usually, the reference (#REF!) error shows up when a cell referred to the excel formula is not valid. This might happen when we move or delete excel columns/rows/sheets which are referred to as a formula. Moreover, this error may happen if you copy a formula that contains a relative reference to a new location where references are not valid. Let’s consider an example of #REF! error. Suppose, I have a dataset containing several items’ sales data and I calculated total sales using formula. Here the summation formula used Cell C5 and Cell D5 as reference.
Now, if I delete column C, immediately #REF! errors appear as the reference column used in the above formula no longer exists.
3 Easy Methods to Find Reference (#REF) Errors in Excel
While working with a large number of data, reference errors might be present anywhere in the worksheet. Searching for #REF errors one by one might seem a time-consuming task. I will show you some methods to find reference (#REF) errors at once, using excel features and VBA.
1. Use ‘Go To Special’ Option to Find Reference (#REF!) Errors
You can use the ‘Go To Special’ option to find reference errors in excel.
Steps:
- Select the entire worksheet that contains reference (#REF!) errors.
- Next press Ctrl + G to bring the ‘Go To’ dialog box. Then click on Special.
- As a result the ‘Go To Special’ dialog box will appear. Now, select the Formulas option and put a checkmark only on Errors. Press OK.
- Consequently, excel will bring you to all the cells that have #REF! errors.
⏩ Note:
- You can bring the Go To Special dialog by following the path: Home > Editing group > Find & Select > Go To Special.
Read More: Errors in Excel and Their Meaning (15 Different Errors)
2. Excel Find Option to Search Reference (#REF!) Errors
This time I will use the Find option in excel to find #REF! errors with the same dataset.
Steps:
- First, select the entire worksheet that has the errors. Then press Ctrl + F to get the Find and Replace dialog box. Now type #REF! in the Find what box and click Find All.
- Upon clicking Find All, you will get a list indicating which cell has the #REF! errors. After you are done with the output, click Close to finish the operation.
Read More: [Fixed] Excel Found a Problem with One or More Formula References in This Worksheet
Similar Readings
- How to Fix “Fixed Objects Will Move” in Excel (4 Solutions)
- [Fixed] Excel Print Error Not Enough Memory
3. Excel VBA to Find Reference (#REF!) Errors
You can identify which cells have #REF! errors using a simple VBA code. Here we used the same dataset as above.
Steps:
- First, go to the worksheet where you want to locate the reference error, right-click on the sheet name, and press View Code to bring the VBA window.
- Now type the below code in the Module and run the code by pressing F5 from the keyboard.
Sub Get_REF()
Dim a As Range
For Each a In ActiveSheet.UsedRange
If a.HasFormula = True And InStr(1, a.Formula, "#REF!", 1) > 1 Then MsgBox a.Address
Next a
End Sub
- Once you run the code, a message box will display the cell reference that has the #REF! errors. Keep pressing OK until you get the last cell reference.
Read More: On Error Resume Next: Handling Error in Excel VBA
VLOOKUP Reference (#REF!) Errors in Excel
You can get reference errors while applying the VLOOKUP function in excel. Such as, while entering the arguments in the formula, if you do not specify the column index properly, #REF! errors will happen.
For example, the below formula returns #REF! because column index number is entered as 4. The reason is here the lookup table has only 3 columns. So, obviously, the formula will return an error.
However, if you insert 2, instead of 4, the error is fixed.
Other Possible Reasons for Excel Reference (#REF!) Errors
- Macro Issues: Sometimes, macro refers to a cell above a function where the cell above that function is in row 1. In that case, you might get #REF errors. In a situation like this, we might need to edit the macro.
- Object Linking and Embedding (OLE) Issues: When an OLE link returns #REF errors, run the program that the link is referencing.
- Dynamic Data Exchange (DDE) Issues: While using DDE make sure you are referencing the right topic. If an error occurs, from excel Trust Center Settings review the external content settings.
Read More: Excel VBA: Turn Off the “On Error Resume Next”
Prevent Reference (#REF!) Errors in Excel
The best way to prevent #REF! error is to prevent its occurrence. Still consider the below points:
- Modify your formula in a way so that the deletion of column/ row/ sheets won’t affect them. For instance, you can use a range of formulas for calculating summation ‘=SUM(C5:D5)’ instead of using a simple summation formula (=C5+D5).
- If deleting cells/columns/sheets that affect your formula, think twice before deleting them.
- Sometimes, you may need to copy formulas to other locations. In such cases try to avoid using relative references, instead, use absolute references in formulas.
Fix Reference (#REF!) Errors in Excel
Fixing #REF! errors are quite tricky. I can mention some basic suggestions as below:
- If you just deleted a cell/row/column and #REF! errors occur as a result of that, just undo the deletion.
- If you have deleted a worksheet, and reference errors appear due to that, just close your excel file without saving it. Then reopen the excel file. We are doing this because, if you delete an excel sheet, there is no option to undo it.
- You can replace the #REF! errors with any other text or value. While doing that, you can use the Find and Replace option in excel.
- Try to fix the errors manually immediately after the error occurs. Sometimes it might need you to do back-calculation while fixing the formula.
Conclusion
In the above article, I have tried to discuss several suggestions to find reference errors in excel elaborately. Hopefully, these methods and explanations will be enough to solve your problems. Please let me know if you have any queries.
Related Articles
- How to Correct a Spill (#SPILL!) Error in Excel (7 Easy Fixes)
- [Fixed!] ‘There Isn’t Enough Memory’ Error in Excel (8 Reasons)
- Excel Error: The Number in This Cell is Formatted as Text (6 Fixes)
- How to Remove Value Error in Excel (4 Quick Methods)
- VALUE Error in Excel: 7 Reasons with Solutions
- Reasons and Corrections of NAME Error in Excel (10 Examples)