+ Reply to Thread
Results 1 to 8 of 8

Macro to find, compare and copy values.

  1. #1
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Macro to find, compare and copy values.

    I have 2 sets of data in my workbook. One set of data is permanent and will never change and is in Sheet 1. This data in Sheet 1 is sorted A to Z. The other data is in Sheet 2 and is being imported from a website so the data can be in any order.

    So Sheet 1 has:
    A1 = Adam B1 = Joe
    A2 = Brian B2 = Martin
    A3 = Joe B3 = Dan

    Sheet 2 for eg would have:
    A1 = Brian B1 = Martin C1 = 5 D1 = 6 E1 = 7
    A2 = Joe B2 = Dan C2 = 6 D2 = 9 E2 = 12
    A3 = Adam B3 = Joe C3 = 7 D3 = 15 E3 = 88


    I want a macro to look at the data in sheet 1 cells A1 and B1 and then find this data in sheet 2 (in this example it would be A3 and B3) and when it finds it then copy the other 3 cells on the row (in this example C3, D3, E3) and paste the values to sheet 1 cell C1.

  2. #2
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Macro to find, compare and copy values.

    Any ideas?

  3. #3
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: Macro to find, compare and copy values.

    See in file, please!

    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Macro to find, compare and copy values.

    Thanks again!!!!!!
    Last edited by ScabbyDog; 09-14-2012 at 09:25 PM. Reason: Solved.

  5. #5
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Macro to find, compare and copy values.

    One last thing Sa DQ, how do I alter the code so that ONLY the first 3 columns to the right of the data gets copied over? So in sheet 2 as per my example above if I had data in Y1, Y2 and Y3 the way the code it now it would copy that data across as well. I would only want the data in C, D and E...

    Thanks again!

  6. #6
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Macro to find, compare and copy values.

    Ah found it. Just change resize value to 3.

  7. #7
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Macro to find, compare and copy values.

    Just trying to modify the above code a little. How would I get it so that it looks ONLY for cells A1 and B1 in sheet 1 and then goes to sheet two and if it finds the two values then copy the figures relating to that data?


    EDIT: Found my answer! SOLVED!

    THANKS!
    Last edited by ScabbyDog; 09-15-2012 at 08:18 AM.

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Macro to find, compare and copy values.

    @ ScabbyDog

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't properly marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

+ 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