+ Reply to Thread
Results 1 to 17 of 17

Using Trim() in the Second Parameter of a Vlookup

  1. #1
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Using Trim() in the Second Parameter of a Vlookup

    I pretty much live in IFFERROR(VLOOKUP(..... I have run in toan issue, every once in while, where the table array data needs to be TRIM()'d. I have used the TRIM() in the first parameter of the VLOOKUP with great success but I can't seem to figure out where to put the TRIM() function for the second parameter(table array), if in fact, you can. I do realize that I can go the area that needs to be TRIM()'d and "fix it" before I do the VLOOKUP but I would prefer to do it all in one formula.

    =IFERROR(VLOOKUP(A1,Sheet2!A:D,2,),0)

    so the Sheet2!A:D data in the Col A needs to be TRIM()'d, but, again, I can't seem to figure out the syntax.

    Thanks in Advance
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Using Trim() in the Second Parameter of a Vlookup

    the trim() only works on cells and not in arrays

    I would suggest then

    trim your existing array and make sure that the future entries are trimmed too.

  3. #3
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Using Trim() in the Second Parameter of a Vlookup

    Hi judgeh59,

    Can you upload a sample workbook if you need a workaround on this... thx


    Regards,
    DILIPandey
    <click on below * if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  4. #4
    Forum Contributor
    Join Date
    09-24-2012
    Location
    York, England
    MS-Off Ver
    Excel 2003/07/10
    Posts
    165

    Re: Using Trim() in the Second Parameter of a Vlookup

    Can you not take a extract, and trim the extracted Col A before doing your LOOKUP ?

  5. #5
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Using Trim() in the Second Parameter of a Vlookup

    Here is the upload....
    Attached Files Attached Files

  6. #6
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Using Trim() in the Second Parameter of a Vlookup

    Hercules - I can "Clean up the data" prior to doing the vlookup....are you talking about doing a TRIM() in the same formula string?....because I'm not sure how to do that....

  7. #7
    Valued Forum Contributor
    Join Date
    02-05-2013
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Excel 2013
    Posts
    571

    Re: Using Trim() in the Second Parameter of a Vlookup

    Hi,

    Why you not use this
    Please Login or Register  to view this content.
    and copy down on empty column and copy value back the result on column A?
    It's more easy than you think a complex formula for to do that.
    Click (*) if you received helpful response.

    Regards,
    David

  8. #8
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Using Trim() in the Second Parameter of a Vlookup

    Okay.. use below formula:-

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    enter this with key combination: ctrl shift enter

    see attached:- ExcelForumUpload.xlsx

    Regards,
    DILIPandey
    <click on below * if this helps>

  9. #9
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Using Trim() in the Second Parameter of a Vlookup

    SDCH - mostly because I never know if the data I'm getting needs to be trimmed and I don't really want to be switching between sheets if I don't have to....I totally understand what you are saying - was hoping for a simple solution....

    DILIPandey - I never even considered an array formula - looks like it works perfectly....thank you for your help and have a star....

    thanks to everybody who had suggested stuff...

  10. #10
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Using Trim() in the Second Parameter of a Vlookup

    you are welcome judgeh59.. glad to help


    Please mark this thread as [SOLVED].. thx

    Regards,
    DILIPandey
    <click on below * if this helps>

  11. #11
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Using Trim() in the Second Parameter of a Vlookup

    DILIPandey - I have marked this as solved, but I don't see any place that shows I gave you a star....am I missing something?

  12. #12
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Using Trim() in the Second Parameter of a Vlookup

    I
    got it.. so if you give 'star' to any user that can be seen by that user in his /her control panel:-

    http://www.excelforum.com/usercp.php


    Regards,
    DILIPandey
    <click on below * if this helps>

  13. #13
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Using Trim() in the Second Parameter of a Vlookup

    thank you Sir

  14. #14
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Using Trim() in the Second Parameter of a Vlookup

    you are welcome sir


    Regards,
    DILIPandey
    <click on below * if this helps>

  15. #15
    Forum Contributor
    Join Date
    09-24-2012
    Location
    York, England
    MS-Off Ver
    Excel 2003/07/10
    Posts
    165

    Re: Using Trim() in the Second Parameter of a Vlookup

    Hi Judgeh59
    No - I wasn't suggesting using Trim as part of your lookup - I meant to add an extra column to your source data that trims out the spaces and then use this as the first column of the data table. If your happy using an array formula thats a better solution.

  16. #16
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Using Trim() in the Second Parameter of a Vlookup

    Hercules - and I have done that in the past because I needed to...and I have recommended that in past also....I was just looking for something I could build in to the formula....the array formula works but does take a bit of a performance it because it generates the array table...I'll probably add the trim to my bag of vlookup tricks but probably recommend to certain user to do it your way (and mine in the past)....thanks for helping and the suggestions....

  17. #17
    Forum Contributor
    Join Date
    09-24-2012
    Location
    York, England
    MS-Off Ver
    Excel 2003/07/10
    Posts
    165

    Re: Using Trim() in the Second Parameter of a Vlookup

    Hello Judgeh59
    Its best to have multiple options available - the array formula is a great tool for achieving awkward tasks provided that you can maintain control. If users who are not familiar with them are able to manipulate the sheets this can create a lot of problems!

    Good Luck!

+ 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