Consulting

Results 1 to 6 of 6

Thread: VLOOKUP not working properly

  1. #1
    VBAX Contributor
    Joined
    Jun 2019
    Posts
    155
    Location

    VLOOKUP not working properly

    Dear Team,

    I am having two work books (Sample 1 and sample 2).

    I need to copy data from Sample 1 (Column D & Column E) to Sample 2 (Column E & Column F) by matching Model (Column B) & M/c Sl.No (Column C).

    For that i am writing VLOOKUP formula "=VLOOKUP(B4&C4,'[Sample 1.xlsx]Sheet1'!$B$2:$H$474,4,TRUE)"

    But this formula is not working as per my condition. It is updating the wrong values on data's.

    I am attaching the files here for your reference.

    Any one help me to short out this issue.

    Is there any other method for doing this also let me know
    Attached Files Attached Files

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try this formula

    =SUMPRODUCT(--(B4='[Sample 1.xlsx]Sheet1'!$B$2:$B$474),--(C4='[Sample 1.xlsx]Sheet1'!$C$2:$C$474),'[Sample 1.xlsx]Sheet1'!$D$2:$D$474)
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Contributor
    Joined
    Jun 2019
    Posts
    155
    Location
    Dear XLD,

    This is not working. Some of the cells only copying from column D in Sample 2.xlsx
    Last edited by elsuji; 12-07-2019 at 10:45 AM.

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    1. VLookup ony checks the first column in the lookup range. The value that VLOOKUP wants to match is not in column B in Sample1.xlsx, only the first part is.

    2. TRUE means to find the closest matching value in column B


    Capture.JPG
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    VBAX Contributor
    Joined
    Jun 2019
    Posts
    155
    Location
    Dear Mr. Paul,

    Is there any other way to copy the data's

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    Quote Originally Posted by elsuji View Post
    Dear Mr. Paul,

    Is there any other way to copy the data's
    The easiest way I know using worksheet formulas is to add a helper column to the VLOOKUP to search

    Capture2.JPG


    And revise the VLookup()

    Capture.JPG
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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