+ Reply to Thread
Results 1 to 9 of 9

Tweak Macro to return entire row if match found

  1. #1
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Tweak Macro to return entire row if match found

    This macro looks for matches of the cell values of col D of Sheet(1) to cell values of col B of Sheet(2) and returns the matched cell.

    Is it possible to return the entire row of the match not just the cell?

    Thank you


    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Tweak Macro to return entire row if match found

    Quote Originally Posted by capson View Post
    This macro looks for matches of the cell values of col D of Sheet(1) to cell values of col B of Sheet(2) and returns the matched cell.

    Is it possible to return the entire row of the match not just the cell?

    Please explain what "return the entire row" means to you.

    Currently the code just writes a value in column L.

    Do you want to replace the existing matched row on the destination worksheet? Are the columns the same on both sheets? It wouldn't seem they are since you're comparing column D to column B.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Tweak Macro to return entire row if match found

    AlphaFrog, I am sorry for being so unclear,

    If say a cell d5 in col D on sheet 1 finds a match in col B of sheet 2 say B100, then on the row of the match (B100) in sheet 2 return the entire row of sheet 1 of which d5 is a member (a5 to lastcol5) to it starting in col L at row L100

    This will NOT replace the existing matched row on the destination worksheet

    The Columns are not the same in both sheets or the same size

    I sure hope that was more clear

    Thanks
    Last edited by capson; 05-16-2014 at 02:28 PM.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Tweak Macro to return entire row if match found

    First test this on a copy of your data.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Tweak Macro to return entire row if match found

    AlphaFrog, thank you for the help, I uploaded a simple file with data to show what I need as I seem incapable of discribing it in words and do not want to keep wasting your time and good will
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Tweak Macro to return entire row if match found

    Here is the file
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Tweak Macro to return entire row if match found

    My new macro was based on your original macro except it returns the entire row.

    Your original macro compared sheet(1) column D to Sheet(2) column B
    This macro looks for matches of the cell values of col D of Sheet(1) to cell values of col B of Sheet(2) and returns the matched cell.

    Your example workbook doesn't have data in sheet(1) column D. So the macros (your original and my new one) will of course error. The example workbook data is not suited for your original macro or my macro. Test my macro on a set of data that your original macro worked on.

  8. #8
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Tweak Macro to return entire row if match found

    AlphaFrog, thank you for your continued engagement, if I change this line

    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.
    Then the choice of what columns to match can be dynamic and everything works beautifully.

    The only problem is that the return of the match does not return the entire row, but only that part of the row that includes the matching cell and the remainder of the row to its right, if there are cells to the left of the matching cell they are not returned

    Thank you again for your help and patients with the mess of my communication.

  9. #9
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Tweak Macro to return entire row if match found

    I don't follow what you're; asking, want, data config.

  10. #10
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Tweak Macro to return entire row if match found

    AlphaFrog everything is working just fine, except, I was asking in my last reply if it is possible to return the entire row if a match is found per comment #3, now, only a partial row is returned, the matching cell and every cell to its right, if there are cells to the left in the row of the matching cell they are not returned.

    Thank you

+ 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. Replies: 6
    Last Post: 05-24-2012, 09:14 AM
  2. Index match to VBA copy the found entire row
    By Sjaaktrekhaak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-20-2009, 03:22 AM
  3. Looking up arrays and returning entire rows if match is found
    By Carlsbergen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2009, 06:18 AM
  4. Replies: 5
    Last Post: 10-11-2008, 04:01 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