Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

Remove extra spaces from the lookup value with TRIM in Excel

Generally, you can use the VLOOKUP function to lookup a value and return the matched value. However, if there are some extra spaces, such as leading spaces or trailing spaces in cells, the formula will return an error value #N/A even if there is a value matched as below screenshot shown. Here this tutorial provides some tricks on solving this job.
doc three way lookup 1


Unbelievable! A tool changes the way on editing and browsing multiple Office documents.

Open files in multiple windows

 

Open files in one tabbed window with Office Tab

ot 图1 箭头 ot 1

In this case, you can combine the VLOOKUP and TRIM functions to lookup value ignoring extra spaces.

Select a blank cell that you will place the result, type this formula

=VLOOKUP("HR",TRIM($B$3:$C$6),2,0)

HR is the lookup value, you also can directly use the cell reference which contain the lookup value, such as =VLOOKUP(F2,TRIM($B$3:$C$6),2,0)

B3:C6 is the table array you use, 2 is the column index you want to return.

Press Shift + Ctrl + Enter key to return the match value.
doc lookup with trim 2

Tip:

If you want to use the general VLOOKUP formula =VLOOKUP(F2,$B$3:$C$6,2,0), you need to remove the extra spaces from the cells firstly.

After free installing Kutools for Excel, please do as below:

1. Select cells you want to look up from, and click Kutools > Text > Remove Spaces. Then in the popping dialog, check All excess spaces option.
doc lookup with trim 3

2. Click Ok, now all extra spaces have been removed from every cell. And now type the formula =VLOOKUP(F2,$B$3:$C$6,2,0) into a cell, press Enter key.
doc lookup with trim 4 doc lookup with trim 5


Sample File

Click to download the sample file


Other Operations (Articles) Related To VLOOKUP

The VLOOOKUP Function
Now this tutorial will explain the syntaxt and argument of the VLOOKUP function, also will provides some basic examples for explaining VLOOKUP function.

VLOOKUP with drop down list
In Excel, VLOOKUP and drop down list are two useful functions. However, have you tried to VLOOKUP with drop down list?

VLOOKUP and SUM
Using vlookup and sum function helps you quickly find out the specified criteria and sum the corresponding values at the same time.

VLOOKUP in a three way
This tutorial introduces a formula to look up three values and return a mated value.

LOOKUP to return default value if not found match value in Excel
In Excel, it will return the error value #N/A if it does not find the matched value while using VLOOKUP function. For avoiding the error value appears, you can use a default value to replace the error value if not found the matched one.



  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns and Keeping Data; Split Cells Content; Combine Duplicate Rows and Sum/Average... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Favorite and Quickly Insert Formulas, Ranges, Charts and Pictures; Encrypt Cells with password; Create Mailing List and send emails...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • Pivot Table Grouping by week number, day of week and more... Show Unlocked, Locked Cells by different colors; Highlight Cells That Have Formula/Name...
kte tab 201905
  • 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!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.