+ Reply to Thread
Results 1 to 4 of 4

If cell in col B contains the same content as the cell above eg. B3=B2 then delete

  1. #1
    Registered User
    Join Date
    04-30-2012
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    88

    If cell in col B contains the same content as the cell above eg. B3=B2 then delete

    Hi there

    I have a set of data with a lot of duplicates. At the moment I'm adding a column and doing =IF(B3=B2,"Duplicate",""), copy and paste values then sorting and deleting all the Duplicates.

    I'd like to do something in VBA that does this automatically and cleanly but am at a bit of a loss as to how that might happen.

    It may well be the case that there are multiple duplicates eg. B2 is the same as B3, B4 and B5.

    B2 should always be the row that remains with the others deleted.

    I've attached some sample data.

    Hope all is clear and thanks in advance for your help.

    Steve
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,947

    Re: If cell in col B contains the same content as the cell above eg. B3=B2 then delete

    On the ribbon under the Data tab, there is a built in function Remove Duplicates. Follow the wizard to remove duplicate entries.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: If cell in col B contains the same content as the cell above eg. B3=B2 then delete

    why not use the remove duplicates option in the data tab?
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Registered User
    Join Date
    04-30-2012
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    88

    Re: If cell in col B contains the same content as the cell above eg. B3=B2 then delete

    For no reason other than my ignorance and incompetence martin!

    Thanks both for your responses, wish I'd known about that some time ago!

+ 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] Match Cell Content and Delete Cell Content If a Match is Found
    By aviatecar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-30-2013, 01:29 PM
  2. IF same CONTENT FOUND IN CELL A THEN DELETE CONTENT IN B,C or D
    By mecutemecute in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-11-2013, 01:16 AM
  3. Macro to delete cell content based on cell value
    By stevetothink in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2013, 10:57 AM
  4. [SOLVED] delete cell content when other cell's content is removed
    By Pretpik in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-11-2012, 11:06 PM
  5. If X Number of Words In Cell, Delete Cell Content, Else Do Nothing
    By sweetrevelation in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-27-2009, 01:15 AM

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