+ Reply to Thread
Results 1 to 6 of 6

Deleting duplicate records (both)

  1. #1
    Registered User
    Join Date
    10-07-2008
    Location
    london
    Posts
    2

    Deleting duplicate records (both)

    Hi all!

    I have 2 columns A and B.

    There are 1000 records in column A and 500 records in column B.

    I would like to compare both columns for duplicate entries and deleting all instances of those record in both columns, leaving behind records that were not duplicated to begin with in their respective columns.

    I hope that was clear!

    Thanks
    Last edited by naithemilkman; 10-09-2008 at 05:53 AM.

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    If this is a one-off, I would:
    Copy the tab (Ctrl + Click & drag tab along tabbar)
    On one copy I would write in C2 =min(countif(A:A,B2),1) and copy it to the end of the (sheet or range - doesn't matter)
    Then I would autofilter the range and show every entry of '1' in column C
    I would then delete these rows
    This would give me all the entries in column B which were not found in column A

    Then I'd flip to the other sheet and put =min(countif(B:B,A2),1) in C2 and same again - those with no duplicates in column A would have a zero in column C - so those with a 1 in column C can be deleted.

    Finally, I'd stick the sheets back together (copy and paste one column onto the other sheet)

    This way is crude but fast as a one-off. If this is a repetetive task I would look at doing it better...

    HTH

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650
    Hi, Try This:-
    code, Deletes Duplicates in column "A" & "B"
    Please Login or Register  to view this content.
    Regards Mick

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650
    Hi, I was thinking if you wanted to delete the duplicate cells, this would be better.
    Please Login or Register  to view this content.
    Regards Mick

  5. #5
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650
    Hi, Have a Read of this:-
    NB:- There is NO Msgbox in your Code, See Below !!

    Inserting a Command Button in worksheet and Allocating Code

    Open your workbook at the Sheet Number with your Data that you want to Manipulate.
    Click View, Toolbars, Control ToolBox,---- Control ToolBox Menu Appears on sheet.
    Slide you cursor over the Tool Box (Tool Tip Text) until you find a Command Button.
    Click It then click Somewhere on the sheet.-- Command Button appears on sheet.
    The Command Button will have handles round its edge, This is so you can Position it on the sheet.
    Click the command Button "Hold the Mouse Click Down" and Drag the Command Button to where you want it.
    Double Click the Command Button, The VB Editor window will appear.
    You can also open the Editor By clicking Alt + F11, but if you double click the Command Button the editor will open in the procedure relating specifically to your Command Button.
    If the VB Editor window has two panes the right pane is where you must paste your code.
    The left pane can be "Project Window" or "Properties Window, Click (Ctrl+R) if not showing.

    Paste your code just under the words "Private Sub CommandButton1_Click() " in the Right hand pane.
    If you have done this correctly. Scroll to the bottom of the code and you should see the words "End Sub"
    On the VB Window, Toolbar you will see a Green Triangular shapes icon,.
    This is to change the VB Editor mode from "Run Mode" to "Design Mode "
    Click this Icon, The Small blue square to its left will change from light blue to dark blue, or Vice Versa. Before you close the Editor make sure this Square is "Dark Blue" i.e. (Reset)
    Sometimes the it will appear Reset when it is not, that why I usually put a message at the bottom of the code, to know if is run or not.(Your msgbox will be he Answers to the count)
    Close the Editor. Select the Command Button and Click it.
    When the code Runs the Msgbox should appear With The Message "The Answers as above" ,if this doesn't happen Open The VB Editor "Alt + F11" and click the "Reset ( Blue Square) and or The "Green Triangle" on the Tool bar . The Blue Square should be "Dark Blue ", in order to run the code..
    NB:- If you want to get back into this specific code through the Command Button.
    Get the Controls ToolBox menu back on the screen, Click the green triangle, When you slide the cursor over your Command button , The cursor shape will change to a "Arrow Headed Cross" , you will then be able to double click it to view your code.
    If you prefer, you can forgo all this hassle by putting the code in an MT macro, with a key combination like (Ctrl+"A") to run it.
    If you still get a problem , call back
    Regards Mick
    Last edited by MickG; 10-08-2008 at 10:12 AM.

  6. #6
    Registered User
    Join Date
    10-07-2008
    Location
    london
    Posts
    2
    hi thanks guys! well in the end i coudlnt work out how to insert the code (im suing ms 2007) and went with the less elegant solution which worked for me. thanks cheeky charlie!

+ 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. How to Sum the Duplicate Records?
    By ramki in forum Excel General
    Replies: 2
    Last Post: 07-23-2012, 11:42 PM
  2. Deleting all records in a access database table from Excel
    By Dave31 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-29-2008, 02:18 PM
  3. Duplicate check and delete for thousands of records
    By bufhal in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-18-2007, 03:04 PM
  4. Replies: 1
    Last Post: 01-17-2007, 11:50 PM
  5. Xl 03 Vba: Matching, & Deleting Both Records
    By Chuckles123 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-28-2006, 04:04 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