How to correct a #REF! error
Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel for iPad Excel for iPhone Excel for Android tablets Excel 2010 Excel 2007 Excel for Mac 2011 Excel for Android phones Excel for Windows Phone 10 Excel Mobile Excel Starter 2010 More…Less
The #REF! error shows when a formula refers to a cell that’s not valid. This happens most often when cells that were referenced by formulas get deleted, or pasted over.
The following example uses the formula =SUM(B2,C2,D2) in column E.
If you were to delete column B, C or D it would cause a #REF! error. In this case we’ll delete column C (2007 Sales), and the formula now reads =SUM(B2,#REF!,C2). When you use explicit cell references like this (where you reference each cell individually, separated by a comma) and delete a referenced row or column, Excel can’t resolve it, so it returns the #REF! error. This is the primary reason why using explicit cell references in functions is not recommended.
Solution
-
If you accidentally deleted rows or columns, you can immediately click the Undo button on the Quick Access Toolbar (or press CTRL+Z) to restore them.
-
Adjust the formula so that it uses a range reference instead of individual cells, like =SUM(B2:D2). Now you could delete any column within the sum range and Excel will automatically adjust the formula. You could also use =SUM(B2:B5) for a sum of rows.
In the following example, =VLOOKUP(A8,A2:D5,5,FALSE) will return a #REF! error because it’s looking for a value to return from column 5, but the reference range is A:D, which is only 4 columns.
Solution
Adjust the range to be larger, or reduce the column lookup value to match the reference range. =VLOOKUP(A8,A2:E5,5,FALSE) would be a valid reference range, as would =VLOOKUP(A8,A2:D5,4,FALSE).
In this example, the formula =INDEX(B2:E5,5,5) returns a #REF! error because the INDEX range is 4 rows by 4 columns, but the formula is asking to return what’s in the 5th row and 5th column.
Solution
Adjust the row or column references so they’re inside the INDEX lookup range. =INDEX(B2:E5,4,4) would return a valid result.
In the following example, an INDIRECT function is attempting to reference a workbook that’s closed, causing a #REF! error.
Solution
Open the referenced workbook. You’ll encounter the same error if you reference a closed workbook with a dynamic array function.
Structured references to table and column names in linked workbooks aren’t supported.
Calculated references to linked workbooks aren’t supported.
Moving or deleting cells caused an invalid cell reference, or function is returning reference error.
If you have used an Object Linking and Embedding (OLE) link that is returning a #REF! error, then start the program that the link is calling.
Note: OLE is a technology that you can use to share information between programs.
Macro Issues
If a macro enters a function on the worksheet that refers to a cell above the function, and the cell that contains the function is in row 1, the function will return #REF! because there are no cells above row 1. Check the function to see if an argument refers to a cell or range of cells that is not valid. This may require editing the macro in the Visual Basic Editor (VBE) to take that situation into account.
Need more help?
You can always ask an expert in the Excel Tech Community or get support in the Answers community.
See Also
Overview of formulas in Excel
How to avoid broken formulas
Detect errors in formulas
Excel functions (alphabetical)
Excel functions (by category)
Need more help?
Want more options?
Explore subscription benefits, browse training courses, learn how to secure your device, and more.
Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.
«Data source reference is not valid» is one annoying problem that can be hard to get rid of, if you don’t know the source problem. In this article, we will learn why data source isn’t valid occurs and how we can solve this annoying problem.
So, as the name suggests the error occurs when Excel tries to refer to location that is no longer available, invalid or doesn’t exist. Now this error can occur due to several reasons.
1: Pivot Tables Data Source Reference is Not Valid
So, when we create a pivot table it requires a data range. Using that data range excel creates the pivot reports. Now if you try to create pivot table with invalid range or refresh pivot table that refers to a range that no longer exists, this can cause «Reference is not valid error».
For example, here I have a data table, initially whose name was «Table1» but I change it to «data» later. Later I wanted to create a pivot table on this table.
So I went to insert —> Pivot tables. When it asked for the data source, I mentioned «Table1». This returns a «Data source reference is not valid» error. Because I do not have any range called «Table1» (I had changed it to «Data»).
So, this one of the main reasons for data reference invalid error.
How to solve Pivot Table Reference Error?
If you have several pivot tables in a workbook that refers to multiple ranges, named range or data tables, make sure that they refer to valid range. When you refresh pivot tables and this error occurs, it is possible that you have changed some range or names in the data mode. Check one by one each of them and save your excel file. This will solve reference error problem.
2: Named Ranges with #REF
The named ranges are great tools when it comes to managing structured data. But you got to be careful with the named ranges. When you name a given range, excel tags that specific name to the given range.
By default excel adjusts the named ranges when you delete or add rows to the named ranges. But if you delete entire range, the named range loses its reference. All the formulas, validations and condtional formatting depending on that range will not work. And if you try to copy that sheet or file you may get «reference is not valid» error.
How to solve named range «Reference invalid error».
To solve this error, use the shortcut CTRL+F3 shortcut. This will open the name manger. Check the names and there ranges. Delete or fix all the named ranges that refers to contains #REF!. Save your file. This will remove the «data source reference is not valid» error.
3: Table Name Change Caused Reference Not Valid Error.
Tables in Excel are great functionality. They help data management a lot. But they can cause the Reference errors to. It is similar to named ranges. When you use Table names in formulas, data validation, conditional formatting, and overtime when you delete or do some major changes to table, excel can through reference not valid error. This may not occur immediately but when you copy ranges or sheets to other workbooks or location.
How to avoid Table Caused Reference Error
To avoid such errors, you should check all the formulas, validations, conditional formatting that refers to table that has changed a lot earlier. Change or delete such formulas. This will solve the » Data Reference not Valid Error»
4: Referencing to Invalid Data Source
Excel has features of importing data from other sources. All these features can be accessed from data tab. «Get external Data», «Power Query», and «Power Pivot» are such examples. These features allow users to maintain data outside the Excel and import them whenever needed.
Now this feature is great but this cause problems when you accidentally or intentionally delete or move data source from the defined location. When the data source does not exist at the defined location, it is obvious that excel shows «Data source reference is not valid».
How to solve Data Source reference is not valid?
Check all the connections your file has. Check the connections to Access database if you have. Check it the location of the data source has changed. This is one of the main reasons of «Data source is not valid» Error. Even if you change the name of the data source, it can cause the error. You need to change the name in Excel connections too.
To solve this error, go to Data —> Get External Data —> Existing Connection. A window will open that will show the existing connection to the workbook. Check the connections and if you don’t need them anymore, remove them. If you do need them. Go to the location of the data source to check if that exist or not.
A lot of time, the connection is valid but file still throws a reference isn’t valid when excel refreshes data. It is possible that the query or table that you are trying to access from the database is changed or does not exist anymore. In that case, you will need to open the data base and check the queries thoroughly. You will find the route cause of the error here surely.
5: Macro Using Undefined Reference
If the error «excel reference isn’t valid» occurs when you run a macro than there can be a lot of reasons.
The first reason can be that macro references to a range that no longer exist in system. This can be easily solved by clicking on the debug method.
Other reason can be the database connection. If you are trying to access database from VBA and trying to run a query with a invalid connection or query than you may get this error. So you have to do all the things mentioned in previous step.
Other reason can be that you used an object whose reference is not added. Like if you want use active data object, you will need to add reference to that object first.
To add a reference to an object, open VBE using Alt+F11 key. Now go to tools in menu, click on References. It will open a dialog box that has all the available resource. Search the object you need. Check it and click OK button. This will add the reference to that object.
So yeah guys, these are the reasons and methods to solve the invalid data source error in Excel. I hope it was helpful. If you are still facing the difficulty removing this error, let me know in the comments section below. Till then keep Excelling.
Related Articles:
13 Methods of How to Speed Up Excel | Excel is fast enough to calculate 6.6 million formulas in 1 second in Ideal conditions with normal configuration PC. But sometimes we observe excel files doing calculation slower than snails. There are many reasons behind this slower performance. If we can Identify them, we can make our formulas calculate faster.
Center Excel Sheet Horizontally and Vertically on Excel Page : Microsoft Excel allows you to align worksheet on a page, you can change margins, specify custom margins, or center the worksheet horizontally or vertically on the page. Page margins are the blank spaces between the worksheet data and the edges of the printed page
Split a Cell Diagonally in Microsoft Excel 2016 : To split cells diagonally we use the cell formatting and insert a diagonally dividing line into the cell. This separates the cells diagonally visually.
How do I Insert a Check Mark in Excel 2016 : To insert a checkmark in Excel Cell we use the symbols in Excel. Set the fonts to wingdings and use the formula Char(252) to get the symbol of a check mark.
How to disable Scroll Lock in Excel : Arrow keys in excel move your cell up, down, Left & Right. But this feature is only applicable when Scroll Lock in Excel is disabled. Scroll Lock in Excel is used to scroll up, down, left & right your worksheet not the cell. So this article will help you how to check scroll lock status and how to disable it?
What to do If Excel Break Links Not Working : When we work with several excel files and use formula to get the work done, we intentionally or unintentionally create links between different files. Normal formula links can be easily broken by using break links option.
Popular Articles:
50 Excel Shortcuts to Increase Your Productivity | Get faster at your task. These 50 shortcuts will make you work even faster on Excel.
How to use Excel VLOOKUP Function| This is one of the most used and popular functions of excel that is used to lookup value from different ranges and sheets.
How to use the Excel COUNTIF Function| Count values with conditions using this amazing function. You don’t need to filter your data to count specific value. Countif function is essential to prepare your dashboard.
How to Use SUMIF Function in Excel | This is another dashboard essential function. This helps you sum up values on specific conditions.
Overview:
Is your Excel spreadsheet is displaying #REF! error in individual or several cells? Want to know how to fix the Vlookup Invalid Cell Reference Error Message? If yes then read the below tutorial and make use of the given solution to solve the Excel error.
Excel is all about formulas, formulas are the key part of this application. And this is the reason Excel provides various functions and formulas to make the work easy for the users.
But as we all know the fact that Excel is a very crucial file and a small mistake can make the entire Excel workbook corrupted or inaccessible. Sometimes while working we place any formula that goes wrong then Excel starts displaying errors.
The Excel Invalid Cell reference is one of the error messages faced by the users when the Excel workbook can’t properly calculate a formula you enter in the cell.
And in this case, the program starts displaying error values in that cell as soon as you complete the formula entry. The error begins with a number sign (#).
So, here in this article check out the working solutions to fix invalid cell reference error VLookup, but before moving forward check out the possible reasons responsible for the error.
Why Is My VLOOKUP Giving Me A Reference Error?
Invalid cell reference error occurs when a spreadsheet formula contains incorrect cell references. This error mainly comes when:
- By mistakenly data containing a row or column gets deleted.
- If a formula has been copied or moved to another cell and the cell reference are incorrect.
- Due to VLOOKUP with inaccurate or faulty range references
- Data used in the formula must get moved, leaving the formula or function with incorrect cell references.
Other Possible Reasons responsible for this:
You may have deleted cells that you might have posted those cells that you moved on the pinnacle of cells passed on by added formulas.
It may be that you might have used the linking of an object and link embedding (OLE) to a program that is not working anymore.
Also Read: How to Fix “Microsoft Excel is waiting for another application to complete an OLE action” Issue
How To Locate Problem With Formula Reference In Excel?
Well tracking the invalid reference error can be very frustrating as you need to look in several places.
Especially in the formulas that are on worksheets, this is very irritating. But here check out some tricks that help you to easily find the problem with the formula reference in Excel.
- Make use of go to the special dialog box to locate the issue easily. Press F5 > select Special to select to go to the cells that contain errors. And after that, you can use the Tab key for moving amongst the cells that Excel selects.
- Or else you can use the Find tool to find out the possible errors. Press Ctrl + F to display the Find and Replace dialog box and search the (#) Also assure to tell Excel to do the searching within the Formulas.
And check if anything is found to see if it error or not. you can also look for the named ranges defined in the workbook.
How To Fix #REF! – Vlookup Invalid Cell Reference Error?
- If the error checker is on, then press the button that displays the next error and click Show Calculation Steps if it emerges. After that go for a declaration that is suitable as per your data.
- Now change the formula or reinstate cells on worksheets by hitting Undo upon Quick Access Toolbar right away your delete or stick cells.
- Start the program that is known for Object Embedding and Linking (OLE).
- Also, check correctly that you make use of the correct Dynamic Data Exchange (DDE) topic.
Automatic Solution: MS Excel Repair Tool
Make use of the professional recommended MS Excel Repair Tool that is the best-suited tool to fix damaged, corrupted or inaccessible Excel files. It can restore all the corrupt Excel files and helps to restore all corrupted Excel files and can recover everything included in the charts, cell comments, worksheet properties, and other data. With the help of this tool, users can repair .xlsx and .xls files.
With extraordinary attributes, this utility tool is ideal for restoring injured data files from cells and columns of the healthier file.
* Free version of the product only previews recoverable data.
Steps to Utilize MS Excel Repair Tool:
Conclusion:
So this is all about the VLookup invalid cell reference error in Excel
Try the given solutions one by one to fix cell reference errors in Excel easily.
Apart from that, you can also make use of the automatic repair utility to fix the error and recover the data stored in it.
Also, we all know how essential Excel application is, so it is important to handle the Excel file properly and follow the best preventive steps to protect the Excel files from getting corrupted.
Despite it, always create valid backup of Excel data and as well scan your system with a good antivirus program for virus and malware infection.
If, in case you have any additional questions concerning the ones presented, do tell us in the comments section below or you can also visit our Repair MS Excel blog.
Good Luck!!!
Priyanka is an entrepreneur & content marketing expert. She writes tech blogs and has expertise in MS Office, Excel, and other tech subjects. Her distinctive art of presenting tech information in the easy-to-understand language is very impressive. When not writing, she loves unplanned travels.
(Note: This guide on how to fix the #REF Error in Excel is suitable for all Excel versions including Office 365)
Facing error messages is the last thing you want to see in Excel. They are quite frustrating to deal with and often difficult to resolve. The Excel #REF! Error is one of the most dreaded error messages in Excel. If you don’t know what you are doing, it may take forever to resolve this error.
But, don’t worry. In this guide, I will give you some practical tips to avoid this error and resolve it easily.
You’ll learn:
- What Causes the REF Error in Excel?
- Method 1: How to Prevent the #REF Error in Excel?
- Method 2: How to Find Multiple #REF! Errors in Excel?
- Method 3: How to Fix the #REF Error in Excel?
Related:
How to Fix the Excel Circular Reference Error?
How to Fix the Excel NAME Error? 3 Simple Tips
How to Fix the Excel Spill Error? — 5 Easy Fixes
What Causes the REF Error in Excel?
Using invalid references inside Excel formulas is the main cause behind the Excel REF error. But, keep in mind that almost all of these invalid references are accidentally created when copying or moving formulas from one cell to another.
Let me explain this with an example.
Let us say you want to calculate the total sales achieved in the last quarter. You calculate this in cell B5 using the formula SUM(B2:B4), but later decide to move it to cell E2. Excel will throw up a #REF error, leaving you confused.
What is even more perplexing is that, if you try to move the formula to cell E9, Excel will return a 0 instead of the #REF error.
So, what is causing all this?
The real culprit behind the Excel REF error is the inappropriate usage of relative references.
You see, when you use the relative reference B2:B4 in the SUM function in cell B5, you are asking Excel to find the sum of the previous three cell values i.e B2, B3 and B4.
When you try to move the formula to cell E2, there are no three cells preceding it. That’s why this is considered an invalid reference and leads to the #REF error. On the other hand, if you try to move the formula to cell E9, there are in fact three cells preceding it albeit empty (E6, E7 and E8). This is the reason, Excel returns a 0 instead of the #REF error.
Method 1: How to Prevent the #REF Error in Excel?
The best way to prevent #REF errors from cropping up is to use absolute references as much as possible. Also, keep in mind that, accidentally deleting rows or columns which are already used in calculations may also lead to reference errors.
Pro Tip: It is always better to resolve #REF errors as soon as they appear (By using the Undo button and using the correct reference). Doing this will save you from a lot of pain and confusion. Otherwise, you will end up spending a lot of time figuring out what caused the REF error.
Method 2: How to Find Multiple #REF! Errors in Excel?
In case your worksheet already has a lot of reference errors, fixing them is going to be quite a challenge, to be honest. But, on the other hand, finding them is very easy.
To find REF errors scattered over an Excel worksheet, just follow these steps:
- Press Ctrl+H on your keyboard and open the Find and Replace dialog box.
- Type #REF! and click on the Find All option. This will highlight all instances of reference errors.
- Click on Find Next to cycle through the list of REF errors in the sheet and fix them one by one.
Also Read:
How to Use Goal Seek in Excel? (3 Simple Examples)
How to Insert Multiple Rows in Excel? The 4 Best Methods
How to Autofit Excel Cells? 3 Best Methods
Method 3: How to Fix the #REF Error in Excel?
The only way to fix a #REF error is to figure out what was wrong with the formula reference before and replace it with the correct reference. The tricky thing is, that this formula is no longer visible. That is why it is highly recommended to resolve #REF errors as and when they arise.
If not, the only way out is to carefully examine the sheet and figure out what should have been the correct formula. In case, a REF error is caused by a deleted sheet or row or column, it is recommended that you restore the previous version of the sheet.
Note: If your #REF error is caused by a VLOOKUP formula, it is most probably due to an incorrect column reference. For example, let us say use the formula =VLOOKUP(B20, C15:D17, 3) but, there is no column 3 in the range C15:D17. This will cause a #REF error. To fix it, just change the index to a proper value.
Suggested Reads:
How to Group Worksheets in Excel? (In 3 Simple Steps)
How to Shade Every Other Row in Excel? (5 Best Methods)
How to Use the Excel Fill Handle Easily? (Top 3 Uses with Examples)
Closing Thoughts
In this guide, we saw how to smartly avoid and fix #REF errors in Excel. I hope you find this guide helpful. If you have any questions, please feel free to ask us in the comments. We are always happy to help.
If you need more high-quality Excel guides, please check out our free Excel resources center.
Simon Sez IT has been teaching Excel for over ten years. For a low, monthly fee you can get access to 130+ IT training courses. Click here for advanced Excel courses with in-depth training modules.
Simon Calder
Chris “Simon” Calder was working as a Project Manager in IT for one of Los Angeles’ most prestigious cultural institutions, LACMA.He taught himself to use Microsoft Project from a giant textbook and hated every moment of it. Online learning was in its infancy then, but he spotted an opportunity and made an online MS Project course — the rest, as they say, is history!
Excel triggers the “..Reference isn’t Valid” error when it cannot locate the cell or range you referenced. While this normally is the case, you will also run into this issue if your Excel file name includes invalid characters.
You may encounter the reference error while creating Pivot Tables, Text boxes or dealing with broken hyperlinks in the Excel program. While you could exit the error message and enter correct references, in some cases this is not possible as all options in the ribbon get grayed out.
Before heading to the fixes, check if your reference is listed as broken or missing. You can check your reference from the Visual Basic for Application (Alt + F11) window. Head to Tools > References.
Exit Design Mode
Many users stumble on this error while creating a text box from the Developer tab. All the ribbon items get grayed out after Excel displays the alert. While you can move between all tabs, you cannot open the File tab.
Even though this error seems out of the blue, it is actually because of a minor human error. When you insert the text box, you must exit the Design mode before you start entering data into the box. However, if you enter your value before exiting the Design mode, you will actually enter your data in the formula bar.
The formula bar initially contains the formula referencing the location of the text box in the grid. When you enter a value that does not refer to a location, Excel will trigger the Reference Isn’t Valid error.
- Click the OK button in the warning message box.
- Select Cancel (X) next to the formula bar.
- From the Developer tab, deselect Design Mode.
Referred Cell Does Not Include Formula: Goal Seek
If you run into this error while using Goal Seek (VBA or What-if analysis), it may be because one of the cells you referred to as Set Cell doesn’t hold a formula. You will also get this alert if you’ve entered a formula instead of a value in the By Changing cell.
To fix this issue, check if you’ve embedded formulas in all cells in the Set Cell range. Additionally, verify that your By Changing cell holds a numeric value, not a formula. After making these changes, run the command again.
Change Pivot Table Named Range
You may have entered an invalid named range while creating a pivot table in Excel. When creating a Pivot Table, you need to enter the cell or named range that exists in the grid.
You must have made a typo while referring to a named cell range, causing Excel to fail to locate your range to create a Pivot Table. Verify your named range from the Name Manager before you create a Pivot Table.
Create a new PivotTable to change your named range.
- Open your worksheet.
- Head to Insert > PivotTable.
- Enter a valid named range in the Table/Range section.
Rename File
You will encounter the Data source reference is not valid error message if your file name has squared brackets. Excel cannot take references from your worksheet if your username contains this special character. Therefore, you cannot perform actions such as creating Pivot Tables that need to take your current worksheet as a reference.
You need to remove the squared bracket from your file name to solve this error.
- Open File Explorer to locate your document.
- Right-click on your Excel file, then click F2.
- Erase the squared brackets from your file name and hit Enter.
Remove Hyperlinks
You could also be dealing with broken hyperlinks if you receive the reference isn’t valid error. The file you linked could be missing or corrupt, making your reference invalid.
You can work around this issue by removing the problematic hyperlinks from your worksheet. If you do not know which hyperlink may be causing this issue, your best bet is to remove all existing hyperlinks.
- Launch your Worksheet.
- Locate the hyperlink from your sheet, then right-click on it.
- Choose Remove hyperlink.
Save the File
Excel may also trigger this error if you try to make changes in an Excel file that isn’t stored on your computer. If you cannot save the document, the creator of the document may have not given you adequate permission.
Check if your file is currently running on Read-Only mode. If you haven’t saved the file locally, use Ctrl + S to save it to your device.