+ Reply to Thread
Results 1 to 6 of 6

Match two columns on different sheets and copy selected cells from one row to other

  1. #1
    Registered User
    Join Date
    01-06-2012
    Location
    Lahore, Pakistan
    MS-Off Ver
    Excel 2007
    Posts
    51

    Match two columns on different sheets and copy selected cells from one row to other

    Dear All, I have a problem in Excel. I need a macro that compare two columns in sheet1 and sheet2 and for matching items from sheet2, copy selected cells from respective rows and paste them in corresponding matching rows in sheet1. My data is as follows, in Sheet1
    Col A , Col B, Col C, Col D, .........................
    Date , Name, ID# , Age
    2/1/11, Ali, A-2145, 17
    3/2/10, Umar, B-2204, 18
    1/1/9, Raza, A-1191, 43
    ......, ......., .........,.....
    ......,........,..........,.....

    whereas in Sheet2,
    Col A , Col B, Col C, Col D, .........................
    ID# , Total Marks, Marks Obtained, Grade, Status,
    L-1412, 500, 417, A , Pass
    B-2204, 800, 622, B , Pass
    C-1214 100, 18, F , Fail
    ........., ....., ....., .. , .....
    ........., ....., ....., .. , .....
    ........., ....., ....., .. , .....
    I want a loop that matches entries in Col C of Sheet1 against the entries in Col A of sheet2 and if it matches, it copies the cells of Marks obtained and grade in respective ROWS and paste them in sheet1 after Colum D, against matched entries.
    I would be grateful for this help. I am a layman to Macros.

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

    Re: Match two columns on different sheets and copy selected cells from one row to other

    Please attach your sample book. To attach, go to advance then attachment

  3. #3
    Registered User
    Join Date
    01-06-2012
    Location
    Lahore, Pakistan
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Match two columns on different sheets and copy selected cells from one row to other

    Please find the attached sample file. Original Data is quite large, its only a small piece to show what it look like. Thanx
    Attached Files Attached Files

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

    Re: Match two columns on different sheets and copy selected cells from one row to other

    Please find attached
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-06-2012
    Location
    Lahore, Pakistan
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Match two columns on different sheets and copy selected cells from one row to other

    Thnk you very much dear AB33. I would be thankful if i would be guided to get the return of Columns (right now "Marks obtained, Grade " are only columns i m getting as a result of Macro) according to my own choice like ( Marks Obtained, Grade, Status) or (Total Marks,Marks Obtained, Status) etc.

    If I add a new column as follows dic.Item(x(i, 1)) = Array(x(i, 2), (x(i, 3), (x(i, 4) ))
    it gives compile error.
    How can i get it resolve?
    Thnx in advance.
    Last edited by tameen42; 04-12-2013 at 06:49 AM.

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

    Re: Match two columns on different sheets and copy selected cells from one row to other

    according to my own choice like

    "copies the cells of Marks obtained and grade" was your choice.
    Attached two codes. Look at the comment after the sub name.
    Attached Files Attached Files

+ 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