+ Reply to Thread
Results 1 to 5 of 5

Vlookup

  1. #1
    Registered User
    Join Date
    05-10-2009
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    8

    Question Vlookup

    Hey there,

    I'm having trouble to get VLOOKUP to work. Basically I need to look up Management Teir information from Sheet1 onto Main sheet as per the file attached. Both RecordID columns are Text so they should work right? But VLOOKUP returns #NA error. Anyone knows what's going on here?

    Any reply greatly appreciated
    Attached Files Attached Files
    Last edited by mfkdghd; 07-14-2009 at 09:34 PM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    re: Vlookup

    Hi mfkdghd,

    First, your text 'Emp No' values on Sheet1 all have five spaces after them. Remove those five spaces and your VLOOKUP functions will start to work.

    Second, your VLOOKUP functions on Main are not using a static table range. Notice how the table to search changes as you go down the rows. To fix this, go to B2 and use:

    =ISERROR(VLOOKUP(A2,Sheet1!$A$2:$B$81,2,FALSE))

    Fill that down to B26. Then in C2 use:

    =IF(ISERROR(VLOOKUP(A2,Sheet1!$A$2:$B$81,2,FALSE)),"Error here",VLOOKUP(A2,Sheet1!$A$2:$B$81,2,FALSE))

    Fill that down to C26. Notice the $'s in the table range, this will keep those cell references static down the entire column of formulas.

  3. #3
    Registered User
    Join Date
    05-10-2009
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Vlookup

    Thank you so much Paul for your prompt yet helpful response! Really appreciate it. I am currently working to fix both.

    I hate to ask again but I am having trouble to trim off the trailing spaces of those Text values. '=Trim(A2)' stays at itself literally whilst I am expecting whatever in cell A2 but trimmed. If I use '=Trim(" Fax")' it returns "Fax" as expected. Can you please advise what's wrong with range reference in Trim()?

    Kind regards
    Frank

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Vlookup

    easiest way is to select all values in col a sheet 1 (but not header row)
    then
    find/replace
    find .... just hit space bar once
    replace ... leave it blank
    replace all
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Registered User
    Join Date
    05-10-2009
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    8

    Smile Re: Vlookup

    Yup Martin find+replace is a much better way to do that than Trim().

    I also managed to get Trim() to work. The trick is to set the cell where =Trim() is located, 'General' rather than 'Text'. So apparently Trim() likes 'General' cell type alot better(Text seems to even treat clearly a formulae literally?)

    Thanks Martin and Paul for being so helpful!

    Regards
    Frank

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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