+ Reply to Thread
Results 1 to 9 of 9

Match 2 Columns in two sheets; copy an offset Column of matched Row to Sheet 1

  1. #1
    Registered User
    Join Date
    03-03-2016
    Location
    Baltimore, USA
    MS-Off Ver
    2007
    Posts
    11

    Match 2 Columns in two sheets; copy an offset Column of matched Row to Sheet 1

    Hello,

    Need a VBA code to match 2 Columns in two sheets; then copy an offset Column from the matched Row of sheet2 to end of the corresponding matching row in sheet1. Please see the sheet "Summary" of the attached workbook to get a clear picture.

    Sheets 1 & 2 both have similar data in Columns A through F, with no more than 300 Rows of Data.
    First, need to delete Rows containing 000 in Column D of both sheets.
    Need to match Columns "D" of sheets 1 and 2. For the matches found,
    - Copy Column A from the corresponding row of sheet 2 to Column G of the matching Row of sheet 1.
    - In Sheet 1, write "Existing" in Column H for the matches, and "New" in Column H for the Rows that did not have a match.
    - If newly written Column G = Column A (ex: G5 = A5), highlight the corresponding Column H (ex: H5)

    If it is convenient to create a third sheet for results instead of writing to Sheet 1, that will be okay.

    I found a similar VBA code that compared the first columns and replaced the entire row. But my knowledge of VBA is so minuscule, I was not able to alter it to suit my needs.

    Many thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Match 2 Columns in two sheets; copy an offset Column of matched Row to Sheet 1

    Try
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-03-2016
    Location
    Baltimore, USA
    MS-Off Ver
    2007
    Posts
    11

    Re: Match 2 Columns in two sheets; copy an offset Column of matched Row to Sheet 1

    Jindon, The code works exactly the way I want. Thank you very much. Much appreciated!!

  4. #4
    Registered User
    Join Date
    03-03-2016
    Location
    Baltimore, USA
    MS-Off Ver
    2007
    Posts
    11

    Re: Match 2 Columns in two sheets; copy an offset Column of matched Row to Sheet 1

    Quote Originally Posted by jindon View Post
    Try
    Please Login or Register  to view this content.
    Jindon, The only hitch is that Column H does not highlight when Column A = Column G. In the workbook example, H7 as G7 = A7. Thought I could figure out, sorry, just couldn't.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Match 2 Columns in two sheets; copy an offset Column of matched Row to Sheet 1

    OOps, can you change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    03-03-2016
    Location
    Baltimore, USA
    MS-Off Ver
    2007
    Posts
    11

    Re: Match 2 Columns in two sheets; copy an offset Column of matched Row to Sheet 1

    Jindon, It still does not highlight. Can there be anything associated with the use of "With .Columns(.Columns.Count)" line?? Thanks

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Match 2 Columns in two sheets; copy an offset Column of matched Row to Sheet 1

    ?........................
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    03-03-2016
    Location
    Baltimore, USA
    MS-Off Ver
    2007
    Posts
    11

    Re: Match 2 Columns in two sheets; copy an offset Column of matched Row to Sheet 1

    Thanks for the response again. I tried the workbook you reattached. All worked except the highlighting. If it highlighted when you ran, perhaps something to do with my version (2007). I can achieve the highlighting with normal conditional formatting. I appreciate for the code. Regards!!

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Match 2 Columns in two sheets; copy an offset Column of matched Row to Sheet 1

    I don't think there is a version difference between 2007 & 2013 reg Conditional Formatting.

    If you say you can add conditional formatting manually, what was the formula then?

+ 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. [SOLVED] Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynamic s
    By drewship in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-15-2015, 12:31 PM
  2. [SOLVED] Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In
    By dylanvv in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 08-17-2015, 09:27 AM
  3. [SOLVED] Compare 2 sheets, match data in 1 column, update row in sheet 2 & add new rows not matched
    By Synchronicity in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 11-11-2013, 01:21 PM
  4. Copy/Paste filtered data from one sheet to another with only matched column headings
    By archerrc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-08-2013, 05:00 PM
  5. Match cells on two sheets, copy columns to sheet 3
    By Marco-Kun in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-23-2013, 09:42 PM
  6. Match two Columns of two Sheets and Copy Matched Rows to a Third Sheet
    By Par in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-08-2012, 10:16 AM
  7. Replies: 0
    Last Post: 10-25-2012, 03:38 PM

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