How to return a value if a given value exists in a certain range in Excel?

When working with data in Excel, it's often necessary to determine whether a specific value exists within a defined range, and if so, retrieve a value from an adjacent cell corresponding to that entry. For example, as shown in the left screenshot, if you are searching for the number 5 within a list or range, you may want to automatically return the corresponding adjacent value – in this case, useful for tasks like looking up product IDs, retrieving user information, or matching codes to values without manual searching.
Return a value if a given value exists in a certain range
Return a value if a given value exists in a certain range by using VLOOKUP function
To quickly retrieve a value associated with a specific entry from a data table or range in Excel, the VLOOKUP function offers a straightforward solution.
This method is particularly effective if your lookup column (where you search for the value) is the leftmost column of your data range, and you want to return data from a column to its right. It's commonly used for searching codes, names, IDs, or reference numbers and fetching related details easily.
1. Select a blank cell where you want the result to appear. Enter the following formula in the Formula Bar:
=VLOOKUP(E2,A2:C8,3,TRUE)
Press Enter to execute the formula. See screenshot:
In this example, if the number 5 (in cell E2) is found within the specified number range in column A (for instance, between 4 and 6), Excel will look up this value and immediately populate the corresponding value from the third column (column C) of range A2:C8 into your selected cell. In the illustration, “Addin 012” is returned because the number 5 is located within the range 4-6.
Note: In the formula, E2 refers to the lookup value, A2:C8 is the data range comprising the lookup values and the returns, and 3 specifies that the return value should come from the third column of the specified range. Adjust these references as appropriate for your worksheet.
Tips & Pitfalls:
- Ensure the lookup range (A2:C8) includes both the lookup column and the return column.
- When using VLOOKUP with the TRUE argument, the lookup column must be sorted in ascending order, or you may get unexpected results.
- For exact matches, use FALSE as the fourth argument, but for range lookups (as in this example), keep it as TRUE.
- If your data changes frequently, double-check your references to avoid misalignment errors.
Return a value if a given value exists in a certain range by using INDEX and MATCH functions
The INDEX and MATCH combination is a flexible method for returning a value when a given value exists in a certain range. Unlike VLOOKUP, INDEX and MATCH can search for a value in any column and return a result from any other column, regardless of order. This is particularly useful if your lookup column is not the leftmost column or if you need more adaptability in your data structure.
1. Select a blank cell where you want the result to appear (for instance, F2). Enter the following formula in the Formula Bar:
=INDEX(C2:C8, MATCH(E2, A2:A8,1))
Press Enter to confirm the formula.
- MATCH(E2, A2:A8, 1) searches for the position of the largest value ≤ E2 in column A. (This requires column A to be sorted in ascending order.)
- INDEX(C2:C8, ...) returns the value from column C at the row number found by MATCH.
This formula looks for the value in E2 within the range A2:A8. If the value is found (for example, 5 is between 4 and 6 in one of the rows), the MATCH function returns its relative position, and INDEX fetches the value from the corresponding row of C2:C8. The '1' in MATCH indicates an approximate match, so make sure your lookup range is sorted appropriately.
- If you want an exact match, use
0
as the third argument in MATCH. - INDEX and MATCH also support both vertical and horizontal data orientation.
- If the value is not found, the formula returns #N/A; consider wrapping with
IFERROR
for friendlier outputs.
Return a value if a given value exists in a certain range by using XLOOKUP function
The XLOOKUP function is a modern alternative for value lookup in Excel365 and Excel2019. XLOOKUP overcomes many of VLOOKUP's limitations, such as restriction on lookup column position and automatic exact/approximate matching.
1. In your desired output cell (for instance, F2), type the following formula:
=XLOOKUP(1, (E2>=A2:A8)*(E2<=B2:B8), C2:C8)
After entering the formula, press Enter to see the result in the selected cell.
- (E2>=A2:A8) checks if E2 is greater than or equal to each value in column A.
- (E2<=B2:B8) checks if E2 is less than or equal to each value in column B.
- Multiplying these two conditions creates an array of 1 and 0, where 1 means E2 is between A and B on that row.
- XLOOKUP(1, ..., C2:C8) searches for the first 1 and returns the corresponding value from column C.
- XLOOKUP dynamically adjusts if columns are inserted or moved, unlike VLOOKUP with fixed column numbers.
- Works for both vertical and horizontal data.
- Requires Excel 365 or 2021; for older versions, use other methods described above.

Unlock Excel Magic with Kutools AI
- Smart Execution: Perform cell operations, analyze data, and create charts—all driven by simple commands.
- Custom Formulas: Generate tailored formulas to streamline your workflows.
- VBA Coding: Write and implement VBA code effortlessly.
- Formula Interpretation: Understand complex formulas with ease.
- Text Translation: Break language barriers within your spreadsheets.
Related Articles:
- How to vlookup value and return true or false / yes or no in Excel?
- How to vlookup return value in adjacent or next cell in Excel?
- How to return value in another cell if a cell contains certain text in Excel?
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
All Kutools add-ins. One installer
Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.





- All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
- One installer, one license — set up in minutes (MSI-ready)
- Works better together — streamlined productivity across Office apps
- 30-day full-featured trial — no registration, no credit card
- Best value — save vs buying individual add-in