+ Reply to Thread
Results 1 to 11 of 11

Macro using VLOOKUP between multiple sheets

  1. #1
    Registered User
    Join Date
    07-27-2011
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    6

    Macro using VLOOKUP between multiple sheets

    I need a macro using VLOOKUP to compare data in Sheet1 Column B with Sheet2 Column C. If they match, I want to have the value in Sheet1 Column E to be copied to Sheet2 Column D.

    I found this macro online and have modified it but I dont think I have the VLOOKUP formula correct. I have that part in red. Please help!

    [code]
    Sub PlaceVlookup()
    'Determine last row based on Sheet 1 Column B
    lastRow = Sheets(1).Range("B" & Rows.Count).End(xlUp).Row
    'Insert formula using lastRow variable
    Sheets(2).Range("D1:D" & lastRow).FormulaR1C1 = _
    "=VLOOKUP(RC[1],Sheet2!RC[3]:R[" & lastRw - 1 & "]C[2],3,0)"
    'Copy/PasteSpecial Values
    With Sheets(2).Range("D1:D" & lastRow)
    .Copy
    .PasteSpecial Paste:=xlPasteValues
    End With
    End Sub
    [code]

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Macro using VLOOKUP between multiple sheets

    Please post a sample workbook

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    07-27-2011
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Macro using VLOOKUP between multiple sheets

    Attached is a sample workbook.
    Attached Files Attached Files

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Macro using VLOOKUP between multiple sheets

    Try:

    Please Login or Register  to view this content.

    Regards

  5. #5
    Registered User
    Join Date
    07-27-2011
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    6

    Smile Re: Macro using VLOOKUP between multiple sheets

    Thanks! It works perfectly!

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Macro using VLOOKUP between multiple sheets

    You're welcome. Thanks for the rep.

    If this has answered your question, please mark your thread as solved. See my signature for details or the FAQ.

    Regards

  7. #7
    Registered User
    Join Date
    03-09-2011
    Location
    los angeles, ca
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    8

    Re: Macro using VLOOKUP between multiple sheets

    I am kinda of new VBA, where exactly did you add that Sub?

  8. #8
    Registered User
    Join Date
    03-09-2011
    Location
    los angeles, ca
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    8

    Re: Macro using VLOOKUP between multiple sheets

    O, I see, TMShucks just created a new sub and that works perfectly!
    Thank you

  9. #9
    Registered User
    Join Date
    07-27-2011
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Macro using VLOOKUP between multiple sheets

    I am running into a problem with this. What if there are multiple book numbers that are the same but have different IBC numbers? How would I include all applicable IBC numbers without deleting any? It could be one long string.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Macro using VLOOKUP between multiple sheets

    Your original question was asked and answered.

    This is a variation/extension to the original problem and I suggest that you open a new thread and upload a sample workbook with some data that demonstrates the issue.

    Regards

  11. #11
    Registered User
    Join Date
    11-27-2013
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2010
    Posts
    1

    Unhappy Re: Macro using VLOOKUP between multiple sheets

    I am running the macro on the downloaded sheet, the IBC column is all getting replaced by #REF!

+ 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