+ Reply to Thread
Results 1 to 22 of 22

Find matching ranges and Copy whole row in sheet2

  1. #1
    Forum Contributor
    Join Date
    02-19-2004
    Location
    San Francisco Bay Area
    MS-Off Ver
    Microsoft 365 Aps for enterprise.
    Posts
    241

    Find matching ranges and Copy whole row in sheet2

    I am wondering if someone can help me on this. I have a sheet with sets of data from two different dates. (Sheet1)
    I like to find data which matches in three col. Tool|Channel|Sample. If the values are same in these three Col. in both sets of data.
    then copy that row and put in Sheet2.
    I would be thankful if someone can help me on this. I am attaching a sample sheet.
    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Find matching ranges and Copy whole row in sheet2

    One way...
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    02-19-2004
    Location
    San Francisco Bay Area
    MS-Off Ver
    Microsoft 365 Aps for enterprise.
    Posts
    241

    Re: Find matching ranges and Copy whole row in sheet2

    Hi Sintek, Thanks for the help. I ran the code and found several of the rows in sheet2 are not matching. Please run the code you will notice that.
    Thanks again.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Find matching ranges and Copy whole row in sheet2

    Code checks two tables in sheet 1 for matches and copies these matches - all rows to sheet2...
    If this is not what you are wanting then please explain in more detail...also upload a sample file showing expected result...
    Do you only want columns A to E copied over or ? .. Oops I notice my code copies entire row...will await feedback and amend code...
    Last edited by sintek; 02-23-2024 at 01:48 AM.

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

    Re: Find matching ranges and Copy whole row in sheet2

    saziz,

    This is how I read your problem.
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    09-23-2020
    Location
    Turkey
    MS-Off Ver
    Office Pro Plus 2016 TR
    Posts
    140

    Re: Find matching ranges and Copy whole row in sheet2

    Master Jindon


    The codes give errors in this line.


    rs.Open "Select Tool, Channel, Sample, Output From [" & e(0) & "] Where Exists(" & _
    "Select * From [" & e(1) & "] Where A.Tool = G.Tool " & _
    "And A.Channel = G.Channel And A.Sample = G.Sample);", cn
    Sheets("sheet2").Range(e(2)).CopyFromRecordset rs: rs.Close

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

    Re: Find matching ranges and Copy whole row in sheet2

    Just tested the code again with the workbook in post #1 and works fine without error.

    Who are you anyway?

  8. #8
    Forum Contributor
    Join Date
    09-23-2020
    Location
    Turkey
    MS-Off Ver
    Office Pro Plus 2016 TR
    Posts
    140

    Re: Find matching ranges and Copy whole row in sheet2

    I downloaded it because it was a general study of the study.

    That's why I saw this error and wanted to tell you.


    I'm actually surprised that you reacted like this. sorry if I disrupted you

    It seems strange that you said, "I'm a member of the forum who follows your work, who are you?"
    Last edited by Tacir; 02-23-2024 at 10:03 AM.

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

    Re: Find matching ranges and Copy whole row in sheet2

    Then you should tell that in the first place.
    I thought the OP is using another name.

    If you are still getting such error, I need to see the workbook with the code.

    As I said, it is working without error here.

  10. #10
    Forum Contributor
    Join Date
    09-23-2020
    Location
    Turkey
    MS-Off Ver
    Office Pro Plus 2016 TR
    Posts
    140

    Re: Find matching ranges and Copy whole row in sheet2

    It is working incorrectly. I downloaded the book in the first file.

    Column header names may be incorrect or have spaces in the file, I don't know.

    picture error link :
    https://ibb.co/nQ46x8R

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

    Re: Find matching ranges and Copy whole row in sheet2

    What do you mean by "incorrectly"?

    As I mentioned, that was how I read the question and I am not sure if the result is what OP wants or not.

    So, I'm waiting for the reply from the OP.

  12. #12
    Forum Contributor
    Join Date
    09-23-2020
    Location
    Turkey
    MS-Off Ver
    Office Pro Plus 2016 TR
    Posts
    140

    Re: Find matching ranges and Copy whole row in sheet2

    I meant that the red code block gives an error.

    Maybe it's a separate topic because we didn't add the necessary Ado references.
    In the picture I added in the link, the code is stuck in the red section and it does not work.


    https://ibb.co/nQ46x8R

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

    Re: Find matching ranges and Copy whole row in sheet2

    Then UPLOAD the workbook.

    No need to add any reference at all!
    Last edited by jindon; 02-23-2024 at 10:23 AM.

  14. #14
    Forum Contributor
    Join Date
    09-23-2020
    Location
    Turkey
    MS-Off Ver
    Office Pro Plus 2016 TR
    Posts
    140

    Re: Find matching ranges and Copy whole row in sheet2

    Once the relevant friend examines it, at least there will be no problem.
    Attached Files Attached Files

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

    Re: Find matching ranges and Copy whole row in sheet2

    Working and if you are getting error, your Excel need to be fixed.

  16. #16
    Forum Contributor
    Join Date
    09-23-2020
    Location
    Turkey
    MS-Off Ver
    Office Pro Plus 2016 TR
    Posts
    140

    Re: Find matching ranges and Copy whole row in sheet2

    The title in the sentence in the code block and the title names in the Excel book seem to be different.

    This type of work is always general. That's why I wanted to examine it. I will also follow the answers of the friend who opened the subject.
    Thanks
    Last edited by Tacir; 02-23-2024 at 10:29 AM. Reason: extstra

  17. #17
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Find matching ranges and Copy whole row in sheet2

    @ saziz...
    You are aware of all the duplicates...See if this is what you wanted...
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 02-23-2024 at 10:35 AM.

  18. #18
    Forum Contributor
    Join Date
    09-23-2020
    Location
    Turkey
    MS-Off Ver
    Office Pro Plus 2016 TR
    Posts
    140

    Re: Find matching ranges and Copy whole row in sheet2

    Hello Mr. Sintek,

    I wrote this because I examined the relevant issue as a separate person.
    I wanted to examine the work other than the friend who opened the subjct.
    I got involved while reviewing Jindon's codes.

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

    Re: Find matching ranges and Copy whole row in sheet2

    What a waste of time...

  20. #20
    Forum Contributor
    Join Date
    09-23-2020
    Location
    Turkey
    MS-Off Ver
    Office Pro Plus 2016 TR
    Posts
    140

    Re: Find matching ranges and Copy whole row in sheet2

    Quote Originally Posted by Tacir View Post
    Once the relevant friend examines it, at least there will be no problem.

    Mr Jindon
    Did you see the book I added?

  21. #21
    Forum Contributor
    Join Date
    02-19-2004
    Location
    San Francisco Bay Area
    MS-Off Ver
    Microsoft 365 Aps for enterprise.
    Posts
    241

    Re: Find matching ranges and Copy whole row in sheet2

    Hi Sintek, Your second code works perfectly.
    I am grateful to you for spending time on this and helping me out.
    Thank you!

  22. #22
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Find matching ranges and Copy whole row in sheet2

    Glad to have contributed...Happy Coding...

+ 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: 3
    Last Post: 07-22-2022, 09:00 AM
  2. [SOLVED] Alter Matching Sub From matching two Ranges to matching one range and list
    By capson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2015, 10:48 PM
  3. MATCHING two sets of data ranges
    By 10999989 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-14-2013, 04:38 AM
  4. Replies: 2
    Last Post: 04-11-2013, 11:14 AM
  5. Replies: 0
    Last Post: 01-22-2013, 08:23 AM
  6. Min/Max Matching Between Ranges
    By cbosch in forum Excel General
    Replies: 4
    Last Post: 07-11-2011, 01:28 PM
  7. Matching values between two ranges
    By hood8jmark in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-01-2008, 09:50 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