Blog
VLOOKUP Not Working? How to Fix #N/A, #REF! and #VALUE!
When VLOOKUP is not working, the formula is usually fine and the data is not. A trailing space, a student ID stored as text, a range that slid down one row every time the formula was copied: each one returns #N/A even though the value is plainly there on screen. When you pull quiz scores from an online quiz export into a 150-student gradebook by student ID, half the rows can fail at once, and the evening before grades are due goes to checking them one by one. Work through the causes in a fixed order and most sheets are fixed in ten minutes.
Start with the formula itself
VLOOKUP searches the first column of a range and returns a value from the same row in another column.
=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
=VLOOKUP(A2,$D$2:$F$500,3,FALSE) looks for A2 in column D and returns the matching value from column F, the third column of the range. Check the last argument first. The Microsoft Learn reference for VLOOKUP explains that when range_lookup is TRUE or omitted, VLOOKUP returns an exact or approximate match, falling back to the next largest value that is less than the lookup value, and the first column must be sorted in ascending order. Only FALSE forces an exact match, and then sorting does not matter.

Even the tooltip warns that the table must be sorted by default. For student IDs, item numbers and other codes, always type FALSE or 0 as the fourth argument. Leaving it blank does not always throw an error. It can quietly return another student's score, which is worse than #N/A because nobody notices until a family asks about the grade.
Six causes of #N/A in VLOOKUP

| Cause | How to confirm | Fix |
|---|---|---|
| 1. Value is not in the table | =COUNTIF(D:D,A2) returns 0 | Add it to the list or flag it as new |
| 2. Number stored as text | ISNUMBER differs between the two cells | Text to Columns, VALUE or TEXT |
| 3. Leading, trailing or hidden characters | =LEN(A2) is longer than it looks | TRIM, CLEAN, SUBSTITUTE |
| 4. Range moved when copied | Lower rows show D3:F501 and so on | Lock with F4: $D$2:$F$500 |
| 5. Lookup column is not the first column | Return column sits to the left | INDEX/MATCH or XLOOKUP |
| 6. Approximate match on unsorted data | Fourth argument is TRUE or blank | Use FALSE, or sort ascending |
1. The value really is missing. That error is correct. It is usually a new student, or a code someone typed in a different form on the other sheet. Check with COUNTIF first, because a 0 there means none of the other causes apply.
2. Numbers stored as text. This is the most common cause. Exports from a student information system, an online quiz tool or a form often store student ID 10023 as text while your roster stores it as a number. A small green triangle in the cell corner is the giveaway. Select the column, go to Data > Text to Columns and click Finish to convert it in place. If your roster is the text side, convert the lookup value instead with TEXT(A2,"0") or A2&"". Codes with leading zeros, such as 00123, should stay text on both sides.
3. Hidden spaces and characters. The Microsoft Learn page lists leading spaces, trailing spaces, mixed straight and curly quotation marks and nonprinting characters as reasons VLOOKUP returns an incorrect or unexpected value. TRIM removes extra spaces and CLEAN removes nonprinting characters such as line breaks. Non-breaking spaces copied from web pages (character 160) survive TRIM, so add SUBSTITUTE(A2,CHAR(160),"").
4. The range moved. The first row works and errors multiply further down. Without dollar signs, each copied row shifts the table range down by one and misses the top of the table. Select the range in the formula bar and press F4, or convert the roster to a table with Ctrl+T and refer to it by name so new rows are included automatically.
5. The lookup column is on the wrong side. VLOOKUP only searches the first column of the range and only returns columns to its right. Looking up a student's name to return the ID on its left is impossible with VLOOKUP alone.
6. Approximate match on unsorted data. With the fourth argument blank, a lookup value smaller than the smallest value in the first column returns #N/A, and anything else returns whatever the sort order happens to land on. Unless you are deliberately using a sorted grading-scale table, where a score of 87 should land on the 80 row and return B, switch to FALSE.
#REF!, #VALUE! and silent wrong results
#REF! appears when col_index_num is larger than the number of columns in the range, for example 4 on a three-column range. Inserting or deleting a column in the lookup table breaks hard-coded column numbers too. Replace the number with MATCH("Quiz 3",$D$1:$F$1,0) so the formula finds the column by its header.
#VALUE! appears when col_index_num is less than 1, and when the lookup value is longer than 255 characters. Look up by code rather than by a long description.
A wrong value with no error is the dangerous case. It usually comes from an omitted fourth argument or a duplicate key in the lookup table. With an exact match, VLOOKUP returns the first value it finds, so test the key column with =COUNTIF($D$2:$D$500,D2)>1 and clean up duplicates before trusting the results.
Lookups into another workbook look like =VLOOKUP(A2,'[Roster.xlsx]Students'!$A:$F,3,FALSE). The last calculated values stay when the source is closed, but renaming or moving the file breaks the link. A roster you look up every week is safer as a sheet inside the same workbook.
Multiple criteria and left lookups
When the value you need depends on two keys, such as grade level and section, build a helper column at the far left of the table that joins them.

With =B2&C2 in the helper column, look up the same combination: =VLOOKUP(G2&H2,$A$2:$E$500,5,FALSE). Join the values in the same order on both sides. Add a separator such as =B2&"|"&C2 so that "12" plus "3" and "1" plus "23" do not produce the same key.
INDEX/MATCH separates the search column from the return column:
=INDEX($B$2:$B$500,MATCH(G2,$E$2:$E$500,0))
It finds G2 in column E and returns the value from column B, so left lookups work. The 0 in MATCH means exact match. In Microsoft 365 and Excel 2021 or later, XLOOKUP is simpler still: =XLOOKUP(G2,$E$2:$E$500,$B$2:$B$500,"Not found") defaults to exact match and takes a not-found message as its fourth argument. Files opened in Excel 2019 or earlier show #NAME? for XLOOKUP, so keep INDEX/MATCH in workbooks you share with colleagues on older versions.
Worked example: matching a weekly quiz export
A ninth-grade biology teacher runs the common Friday quiz for her grade-level team. Every week she downloads a 280-row results file from the online quiz tool with student IDs, names and scores. Column C holds =VLOOKUP(A2,Roster!$A$2:$F$1200,4,FALSE) to bring in each student's section from the grade-level roster, so the scores can be split by class. This week 131 rows return #N/A.
She splits the failures in the order of the table. In a spare column she enters =COUNTIF(Roster!A:A,A2). COUNTIF treats the number 10023 and the text "10023" as the same value, so any row where COUNTIF is 1 or more but VLOOKUP fails is a data-type problem. Rows where COUNTIF is 0 get a second check with =LEN(A2) to separate trailing spaces from truly missing students. The result:
- 98 rows: student IDs stored as text. Text to Columns on column A fixed them at once.
- 17 rows: trailing spaces students typed after their ID. A
=TRIM(A2)helper column fixed them. - 9 rows: students who typed their school email username instead of their ID, which will never be in the roster.
- 7 rows: students who transferred in this week and aren't on the roster yet.
For the nine usernames she builds a two-column mapping sheet, username and student ID, and adds a step in front of the section lookup: =IFERROR(VLOOKUP(A2,Map!$A:$B,2,FALSE),A2). If the username is in the map, it is translated; if not, the original value passes through. The seven new students keep their #N/A on purpose and are highlighted for the front office to add to the roster, because hiding them with IFERROR would bury exactly the rows that need attention. Next Friday the map already exists, and only new usernames need adding. If matching quiz exports is a weekly chore for you, see how inline AI works with quiz exports and score sheets.
👉 How to Use VLOOKUP in Excel: Exact Match and Other Sheets
FAQ
Q. The value is clearly there, but VLOOKUP still returns #N/A.
Compare the two cells directly with =A2=Roster!A15. If it returns FALSE, compare LEN() for spaces and ISNUMBER() for data type, and the cause shows up immediately.
Q. How do I show a blank or "Not found" instead of #N/A?
Wrap the lookup in IFNA: =IFNA(VLOOKUP(…),"Not found"). IFNA handles only #N/A, so a #REF! from a broken range still shows. IFERROR hides every error type, which is fine for a finished report and risky on a working sheet.
Q. Is VLOOKUP case-sensitive?
No. It treats "ab-100" and "AB-100" as the same. For a case-sensitive match, use =INDEX(B:B,MATCH(TRUE,EXACT(A:A,G2),0)).
Q. Can VLOOKUP match part of a value?
Yes, with exact match and a text lookup value, you can use * for any sequence of characters and ? for a single character. =VLOOKUP("*"&G2&"*",$A:$C,3,FALSE) returns the first row containing G2. Put a tilde before a real asterisk or question mark.
Match quiz scores to your roster with inline AI
inline AI opens the quiz export and your roster side by side on your PC, sorts every #N/A row into data type, hidden spaces, username or new student, and fixes the clear-cut ones so each score lands next to the right name. What's left is a short list of rows that need you, such as students who aren't on the roster yet.
Gradebooks and spreadsheets, finished by inline AI in the file itself.
Ask in one sentence for roll-ups, trackers and the cleanup you repeat every week. Your files never leave your computer.





