+ Reply to Thread
Results 1 to 11 of 11

vlookup with spaces

  1. #1
    Forum Contributor
    Join Date
    12-12-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    448

    vlookup with spaces

    Hello. I use vlookup formulas but sometimes the reports that are generated have spaces before or after words because the people that generate them are idiots. How do I do a vlookup that ignores the spaces. For example, if I want to lookup "Dogs" and I keep this as my lookup value but the value in the report is "Dogs__" with the line indicating a spaces. Obrigado.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: vlookup with spaces

    Use the trim function...

    Example: =VLOOKUP(TRIM(A1),$F$1:$G$17,2,0) >> A1 is the lookup value of dogs against the table in F1:G17
    HTH
    Regards, Jeff

  3. #3
    Forum Contributor
    Join Date
    12-12-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    448

    Re: vlookup with spaces

    Ok, but the lookup value is constant. The report is what is changing, so this trim doesn't help Is there another formula?

  4. #4
    Forum Contributor
    Join Date
    12-12-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    448

    Re: vlookup with spaces

    Another weird thing I noticed is that if you have a space before the value it works, but not if you have spaces after...Why is that?

  5. #5
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: vlookup with spaces

    How about...

    =VLOOKUP(A1&"*",$F$1:$G$17,2,0)
    Last edited by jeffreybrown; 07-10-2013 at 07:24 PM. Reason: Posted the wrong formula...Sorry :(

  6. #6
    Forum Contributor
    Join Date
    12-12-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    448

    Re: vlookup with spaces

    Isn't that the same thing? The A1 does not need to be trimmed. I'm looking in the range (which is where the format changes), so that is the value that needs to be trimmed but that seems difficult.
    Last edited by amartino44; 07-10-2013 at 07:24 PM.

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: vlookup with spaces

    Sorry, posted the wrong formula...

    Check the update in #5

  8. #8
    Forum Contributor
    Join Date
    12-12-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    448

    Re: vlookup with spaces

    That worked. Why did that work haha? What is the "*"?

  9. #9
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: vlookup with spaces

    Not sure if I have an answer for why Trim did not work, but the "*" simply means, look for the lookup word and it doesn't matter what after it.

  10. #10
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: vlookup with spaces

    that stands for
    A1 + anything after wards

    some other useful wildcards found here
    http://office.microsoft.com/en-au/ex...005203612.aspx
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  11. #11
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: vlookup with spaces

    trim didnt work because the lookup didnt have the extra spaces the values in the array/range did

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1