+ Reply to Thread
Results 1 to 13 of 13

Compare columns and copy entire row

  1. #1
    Registered User
    Join Date
    05-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    24

    Compare columns and copy entire row

    I have a workbook with 2 worksheets in it. I have column A in sheet 2 with course numbers. This list consists of numbers and letters.

    Sheet 1 has a report generated from another program.

    I need to compare all of the course numbers in sheet 2 column A to the entire list in sheet 1 column A. When there is a match I need the entire row copied from sheet 1 to sheet 3.


    Any help would be greatly appreciated.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Compare columns and copy entire row

    Possible! Could you please attach your sample. Go to advance then attachment

  3. #3
    Registered User
    Join Date
    05-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Compare columns and copy entire row

    No Show YTD (2).xlsx

    Here is the file

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Compare columns and copy entire row

    I found 10 matches. I am assuming you are looking for exact match.

  5. #5
    Registered User
    Join Date
    05-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Compare columns and copy entire row

    Yes.

    I forgot to mention also, that each month the list on sheet 1 will get longer.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Compare columns and copy entire row

    You can have as large data as you like. There will be no issue on speed. The outcome is a new sheet, not fixed sheet, so when ever you run the code, it will produce the result in new sheet, but if you want it to a fixed sheet, this is easily can be changed.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    05-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Compare columns and copy entire row

    That looks great.

    Thank you AB33 for your help.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Compare columns and copy entire row

    twhite79,
    You are welcome!
    Could you please now close (Mark) this thread as solved? Go in to the top right-hand side of this page, choose "Thread Tools" from the menu, then select "solved" from the drop down menu.

  9. #9
    Registered User
    Join Date
    05-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Compare columns and copy entire row

    Upon checking this code, I noticed that this code doesn't work perfectly. I manually removed the extra data from the other 250 rows. When I click the execute button, I expected to see a copy of the data that is now on sheet 1. There are some rows missing from the new sheet.

    Please see attached.

    No Show YTD (2)(1).xlsm

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Compare columns and copy entire row

    Okay!
    I did not trim the cells, hence some of the cells have been missed. I have now corrected, but could not find this line you have include in sheet1( 77477)
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    05-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Compare columns and copy entire row

    Thanks for your help, but when I execute the code I get the same results as before. I am sure it is something simple on my end but am not sure what. I opened the spreadsheet that was sent and sheet 3 is what was returned. I have attached it for your review.

    No%20Show%20YTD%20(2)(2).xlsm

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Compare columns and copy entire row

    Please delete all sheets except the 2 sheets(sheet1 and sheet2) and run the code. You will see the result in new sheet with 27 lines.

  13. #13
    Registered User
    Join Date
    05-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Compare columns and copy entire row

    I figured it out. I put the original code inside the commandbutton macro. It was changed in the module area. I copied the new code that you provided to the commandbutton code and it works great. Thanks for your help.

+ 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