+ Reply to Thread
Results 1 to 5 of 5

VB Code to find duplicate and copy records

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB Code to find duplicate and copy records

    Hello:

    I have data as shown in Sheet1
    I have sorted Ascending order Column B

    I need VB COde to go thru the each text in column B and if it has duplicate
    then copy the records in column H thru K

    Few Example i have manually copied

    Please let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,352

    Re: VB Code to find duplicate and copy records

    Hey Riz,

    VBA is hard but you can get the same answer with a helper column. See the attached where I added a helper column which counts for duplicates. Then you can AutoFilter to only show 2 in the helper and your answer is easy peasy.Duplicate Helper for Riz.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: VB Code to find duplicate and copy records

    Sub J3v16()
    Dim Rng As Range, lr As Long
    With Sheet1
        lr = .Cells(.Rows.Count, 1).End(xlUp).Row
        Set Rng = .Range("F1:F2"): Rng(2).Formula = "=COUNTIF($B$2:$B$" & lr & ", B2)>1"
        With .ListObjects(1)
            .Range.AdvancedFilter 1, Rng
            .DataBodyRange.Copy .Parent.Range("H2")
        End With
        .ShowAllData: Rng.Clear
    End With
    End Sub
    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 [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  4. #4
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to find duplicate and copy records

    Hello
    Thanks Sinteck and Marvin
    R

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: VB Code to find duplicate and copy records

    Pleasure...Tx for rep +
    Last edited by Sintek; 03-11-2021 at 10:11 AM.

+ 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] VB Code to copy duplicate records
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-06-2019, 08:25 AM
  2. [SOLVED] VBA code Error: find the records that match the criteria in a specified cell and copy
    By meer_ali in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 01-02-2014, 03:30 AM
  3. [SOLVED] Find Max date from a list of duplicate records
    By irfanparbatani in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-24-2013, 12:45 AM
  4. How to find the duplicate records
    By koolguys4u in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-25-2009, 12:59 PM
  5. How to find duplicate records in Datalist
    By TST in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-30-2008, 01:11 PM
  6. Find duplicate records in Excel 2003
    By Wayne in forum Excel General
    Replies: 1
    Last Post: 03-28-2006, 07:50 PM
  7. Can you find duplicate records in excel
    By Janet in forum Excel General
    Replies: 1
    Last Post: 04-25-2005, 10:06 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