Trim Range in Vlookup?

beckys

Board Regular
Joined
Apr 19, 2005
Messages
116
I have a very simple formula to do a vlookup:

=Vlookup(E2, MSP!C:I, 7, false)

Column C of the MSP tab has stock symbols - however, the source file that this tab gets populated with has spaces after the symbols, and they do not match the data in E2.

For example, column C of the MSP tab will show "MSFT "
while cell E2 would show "MSFT".

Is there any way to trim column C of the MSP tab within the formula or will we have to continue to do this as a separate step?

Thanks!
Becky
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hello Becky,

You can use TRIM on the table array ....but that will make it an "array formula". It's best to restrict the range so try something like

=VLOOKUP(E2,TRIM(MSP!C$2:I$100),7,FALSE)

confirmed with CTRL+SHIFT+ENTER

adjust range as required

Note that will also "trim" the returned value.....

A better approach might be to use a wildcard like this

=VLOOKUP(E2&" *",MSP!C$2:I$100,7,FALSE)

Note that assumes that your "space" is actually a space and not some other "non printing character"
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,391
Members
452,909
Latest member
VickiS

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top