+ Reply to Thread
Results 1 to 2 of 2

Macro to loop through one column and find a match from other column, then copy data

  1. #1
    Registered User
    Join Date
    04-02-2011
    Location
    Espoo
    MS-Off Ver
    Excel 2007
    Posts
    16

    Macro to loop through one column and find a match from other column, then copy data

    Hi all!

    I have this macro problem that is driving me crazy.

    How do I build a macro that first loops through one column (col A) and then one by one compares col A's values to different sheet's col C finding a match eventually. Then copies some data from the matching row. The loop goes on and second value in col A gets to matched with col C's values.

    The number of rows in col A is unknown. Every value should have a match though in col C. When the match is found some data is copied from columns next to col C next col A in the same row.

    I know that this would be really easy to solve with VLOOKUP or INDEX & MATCH but the point is to have a macro to do this because there is so much data.

    I made a small excel example so it might be easier to understand what I'm after. I'm really stuck with making these two loops to work and would really appreciate help with them. Of the other stuff in the macro I might be able to manage (knocks on wood). Thanks a lot anyways, great forum!
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    04-02-2011
    Location
    Espoo
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Macro to loop through one column and find a match from other column, then copy da

    Yes, now managed to build a very basic macro to loop through both columns and mark an "X" when it finds a match. Don't have time to test it thoroughly right now but based on a quick glance seems like working. This a good start!

    Please Login or Register  to view this content.

    edit. Nested loop was the keyword that I was looking for.
    Last edited by sepi; 05-06-2011 at 03:10 AM.

+ 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