+ Reply to Thread
Results 1 to 13 of 13

Match cell value in another workbook & return adjacent cell value

  1. #1
    Registered User
    Join Date
    09-30-2008
    Location
    USA
    MS-Off Ver
    2010
    Posts
    36

    Match cell value in another workbook & return adjacent cell value

    I'm using the following code and it does exactly what I need. Only issue: I have to drag from row 2 to 62,000 or more from several files several times a day. It became a big time consuming.

    I need to do this via macro.

    =IF(COUNTIF([external.xls]Sheet1!$A$1:$A$100000,A2),VLOOKUP(A2,[external.xls]Sheet1!$A$1:$Z$62000,2,FALSE),0)


    Basically this code match the values in column A in both files and insert the value of the column B of the external file in a column specified in the working file. The column to insert the value is specified with the number you can see just before "FALSE".

    Thank you in advance.

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

    Re: Match cell value in another workbook & return adjacent cell value

    only thing missing is the right destinationcol...

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-30-2008
    Location
    USA
    MS-Off Ver
    2010
    Posts
    36

    Re: Match cell value in another workbook & return adjacent cell value

    Hi rcm,
    Thank you for your reply.

    Actually I got this error:

    Sub or function not defined on this line: ws2 = Workbook("chambersNJ.xlsx").Sheets("sheet1")

    The destination column is not always the same. I use the number before FALSE to indicate on which one I want insert the values. In the example provided, destination column is B.

  4. #4
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    199

    Re: Match cell value in another workbook & return adjacent cell value

    would it also be possible to make this start at and below a specific row on each sheet (to skip a different number of 'header lines' on each sheet)?

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

    Re: Match cell value in another workbook & return adjacent cell value

    #1
    try

    Please Login or Register  to view this content.
    my mistake

    #2

    send a sample of the sheets.. or is there an especific characteristic in the first line of data?

  6. #6
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    199

    Re: Match cell value in another workbook & return adjacent cell value

    The data is a column of VLAN numbers paired to a column of customer names.

    I import data from another application that gives me customer names. I have to research and determine VLAN numbers through other applications. As I do that, I log into another system and determine which MAC address is used by the VLAN from the first sheet. I enter that VLAN on the second sheet and have to go back to the first to copy and paste the customer name. This VLOOKUP idea sounds like the perfect lazy way out.
    The first sheet has customer names starting on H14. I will have to determine the VLAN number to enter in G14. The second sheet starts on row 6. As I determine VLAN numbers, I enter them starting at E6. I will only find VLAN numbers based on the name in the first sheet. So, when I put a matching VLAN number in Column E, I would like it to match that number on the other sheet in column G, copy the customer name in column H and put that into column D on the second sheet.

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

    Re: Match cell value in another workbook & return adjacent cell value

    please send a sample with dummy names an vlans, i'll adjust the macro to fit in

  8. #8
    Registered User
    Join Date
    09-30-2008
    Location
    USA
    MS-Off Ver
    2010
    Posts
    36

    Re: Match cell value in another workbook & return adjacent cell value

    Hi rcm,

    Now I don't get error but nothing happen. Here are some samples of sheets for better understanding.

    The file external.xls has over 20,000 email addresses in column A, a URL in column B and other data on other columns.
    The file chamberNJ.xls has email addresses in column A. Some of these emails are also in the file external.xls.

    I want run the macro and for each email in chamberNJ.xls that match the email in file external.xls, insert the column B value of external.xls in a given column of file chamberNJ.xls.

    I already ran my code on file chamberNJ.xls, Column C so you can see how it works.

    I need to be able to specify the column giving the data and the column receiving the data. Actually what I do is run the code in the column I want receive the data. Once it is automatic, it should be indicated on code, right?

    Thank you for your help, I appreciate that.
    Attached Files Attached Files

  9. #9
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    199

    Re: Match cell value in another workbook & return adjacent cell value

    Please Login or Register  to view this content.
    In Tab1, I will be given a list of customer names in ColumnH. I have to manually find and enter a number from another app into ColumnG for that customer.
    When I switch to Tab2 and find the line to enter the same number in ColumnE, if that number is inTab1:G, copy the name from Tab1:H to Tab2:D.

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Match cell value in another workbook & return adjacent cell value

    @Rhudi

    your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread. With 21 posts you really should know this.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

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

    Re: Match cell value in another workbook & return adjacent cell value

    try the macro on the ..NJ.xls workbook. have the external.xls openned as well.
    Attached Files Attached Files

  12. #12
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    199

    Re: Match cell value in another workbook & return adjacent cell value

    Please forgive my inappropriate tag-along question. If a moderator could remove my entries on this, I would be grateful.

  13. #13
    Registered User
    Join Date
    09-30-2008
    Location
    USA
    MS-Off Ver
    2010
    Posts
    36

    Re: Match cell value in another workbook & return adjacent cell value

    rcm,
    I must say this is AWSOME! - It does exactly what I wanted. Thank you for helping me on this.

    There is only one question left, How can I put the "0" in the rows that does not match as I did with the manual code?

+ 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