+ Reply to Thread
Results 1 to 12 of 12

Macro that Matches up two different columns of data

  1. #1
    Registered User
    Join Date
    04-30-2013
    Location
    arizona
    MS-Off Ver
    Excel 2010
    Posts
    96

    Macro that Matches up two different columns of data

    Hello,
    I have a macro that I am working on which I have gotten stuck on. It compares Column A and Column C and any numbers which match are pasted into Column D.
    What I am getting stuck with is I need to copy and paste the data for column B to Column E as well. So in other words. If column A and B match then the number from Column A that matches B will be pasted
    in column D along with the value that is right next to it in Column B.

    Also, if anyone knows of a more efficient way to write this code that would be great too.
    Thanks,

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by glide2131; 06-24-2014 at 11:03 AM.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013
    Posts
    17,096

    Re: Macro that Matches up two different columns of data

    Please Login or Register  to view this content.
    But why?

    VLookup function will do the job and much much faster...

  3. #3
    Registered User
    Join Date
    04-30-2013
    Location
    arizona
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: Macro that Matches up two different columns of data

    Worked great thanks. I may have several different people using this spread sheet and I did not want one of them to easily change the formula.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013
    Posts
    17,096

    Re: Macro that Matches up two different columns of data

    Quote Originally Posted by glide2131 View Post
    I may have several different people using this spread sheet and I did not want one of them to easily change the formula.
    I mean
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-30-2013
    Location
    arizona
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: Macro that Matches up two different columns of data

    Thats even better thanks. Also, some of the values in column A are based on formulas and the macro does not seem to be picking them up. In fact after I run it once the macro does not seem to work with that row ever again.
    Do you know how to fix that part?

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013
    Posts
    17,096

    Re: Macro that Matches up two different columns of data

    I can not replicate your problem here, so I need to see your file.

  7. #7
    Registered User
    Join Date
    04-30-2013
    Location
    arizona
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: Macro that Matches up two different columns of data

    Ok, so maybe you can think of an easier way to do this. The numbers in column A represent a file folder. The numbers in column C represent a bunch of random documents that have been given naming conventions. I want the macro to match the document name in column C with the file name in column A along with its folder location that is in Column B.
    The only problem is that the beginning of the naming convention is the same but the end is different. For example. all our naming conventions start with a series of numbers than a "." then the name of the document. IE: "000-00-000.BlankDocument.2014" So my idea was to list file numbers in column A of Sheet 2 and list the naming convention in cell B2 of sheet1 and then combine them using a formula. However, the macro would not find the file names in Column A unless I typed them in.
    If that does not make sense let me know. I have attached a new workbook.
    Thanks again for your help.
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013
    Posts
    17,096

    Re: Macro that Matches up two different columns of data

    You have no match. Because your formula is adding a space at the end.
    Change the formula to
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-30-2013
    Location
    arizona
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: Macro that Matches up two different columns of data

    I don't know how I missed that. You are great! Thanks again.

  10. #10
    Registered User
    Join Date
    04-30-2013
    Location
    arizona
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: Macro that Matches up two different columns of data

    Sorry to bug you again. I had to make a change to this macro. I wanted to place a button on another sheet named "Input" and your code only works on the active sheet. Would you be able to show me how to convert it to a specific sheet?
    Thanks a ton.

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013
    Posts
    17,096

    Re: Macro that Matches up two different columns of data

    Change the sheet name
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    04-30-2013
    Location
    arizona
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: Macro that Matches up two different columns of data

    That did it. Thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 09-26-2013, 12:16 PM
  2. Macro that matches columns and pastes to two new columns for eleven different users
    By njmiller31 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2012, 10:19 PM
  3. [SOLVED] Macro to locate matches between data in two columns on two seperate sheets
    By bojangles_73 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-07-2012, 08:10 PM
  4. Replies: 0
    Last Post: 08-11-2012, 03:25 PM
  5. Need a macro that compares 2 columns in 2 worksheets and can highlight any matches?
    By tomqueens in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-19-2012, 10:50 AM

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