+ Reply to Thread
Results 1 to 4 of 4

vlook up problems need sort?

  1. #1
    Registered User
    Join Date
    10-10-2006
    Posts
    7

    vlook up problems need sort?

    For the life of me I can't get this vlookup to work..

    I have this file.. VB i called it. I need to do vlookup in column B. If it matches the id in the second file(master deptid) it is supposed to return the second column which is the description. Does it need to sorted or something ? because it keeps coming up with N/A. Also, if the entry doesn't exist.. it should just return blank.

    =VLOOKUP(A3,'MASTER DEPT ID 3table.xls'!$C$2:$D$635,2)
    That is what I was trying to use. Thanks for any input you guys might have.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by mws5872
    For the life of me I can't get this vlookup to work..

    I have this file.. VB i called it. I need to do vlookup in column B. If it matches the id in the second file(master deptid) it is supposed to return the second column which is the description. Does it need to sorted or something ? because it keeps coming up with N/A. Also, if the entry doesn't exist.. it should just return blank.

    =VLOOKUP(A3,'MASTER DEPT ID 3table.xls'!$C$2:$D$635,2)
    That is what I was trying to use. Thanks for any input you guys might have.
    if it's not sorted then try

    =VLOOKUP(A3,'MASTER DEPT ID 3table.xls'!$C$2:$D$635,2,False)

    hth
    ---
    Si fractum non sit, noli id reficere.

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    For VLOOKUP to work correctly you need to have the same data type for LOOKUP value (A3) and LOOKUP range ('MASTER DEPT ID 3table.xls'!$C$2:$C$635) but A3 is numeric and the range in table.xls is text.

    One way to solve this is to change the table.xls range to numeric. Select column C

    Data > Text to Columns > Finish

    that's it.

    As your lookup range is not sorted you need Bryan's suggestion, a 4th argument for VLOOKUP of FALSE or 0.

    This will still give you #N/A when the number doesn't exist in the table so to return a blank try this formula copied down

    =IF(ISNA(MATCH(A3,'MASTER DEPT ID 3table.xls'!$C$2:$C$635,0)),"",VLOOKUP(A3,'MASTER DEPT ID 3table.xls'!$C$2:$D$635,2,0))

  4. #4
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    Try this:

    =IF(ISERROR(MATCH(""&A3,'MASTER DEPT ID 3table.xls'!$C:$C,0)),"",INDEX('MASTER DEPT ID 3table.xls'!$B:$B,MATCH(""&A3,'MASTER DEPT ID 3table.xls'!$C:$C,0)))

    I think there were 2 problems with using VLOOKUP for this (one of which also applies to using MATCH & INDEX for this).

    Problem #1: (applies to both MATCH & VLOOKUP) the entries in Column A of "vb" file appear to be numeric, while the entries in Columns A & C of the "MASTER DEPT ID" are text. That is why you found no match, I think.

    Problem #2: (applies only to VLOOKUP) with VLOOKUP, the "lookup" column must be the first column, and the "return" column must be to the right of the "lookup" column. Using MATCH, you can return the row number where the match was found, then using INDEX you can return the results from any column you choose.

+ 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