+ Reply to Thread
Results 1 to 9 of 9

Conditionally remove duplicate data

  1. #1
    Registered User
    Join Date
    03-09-2020
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    15

    Conditionally remove duplicate data

    Hi everyone,

    I want to get rid of duplicate data e.g. my data has "303 Air and spacecraft and related machinery" and "3030 Air and spacecraft and related machinery."

    However I can't simply get rid of the duplicate data the normal way because the data is replicated for 26 other countries so simply getting rid of "Air and spacecraft and related machinery" would get rid of the values for the other 26 countries and also, the cell is different because one has code "303" and one has code "3030" even though the data is the same.

    Attaching a sample data set. Bearing in mind that the original data has over 140 products per country with an unknown amount of duplications, is there any way to solve this? Perhaps using some sort of macro?
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    01-14-2013
    Location
    Austria
    MS-Off Ver
    2016 / 2019
    Posts
    339

    Re: Conditionally remove duplicate data

    as long as only numbers changes and the text remains the same then remove the number with (change your data into a table)
    Please Login or Register  to view this content.
    Then you can easily sort or remove duplicates

  3. #3
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Conditionally remove duplicate data

    Does this help? Use a couple of helper columns and then filter by column G to delete the dups. A value in column G greater than 1 means dup.
    Attached Files Attached Files
    HTH
    Regards, Jeff

  4. #4
    Registered User
    Join Date
    03-09-2020
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    15

    Re: Conditionally remove duplicate data

    Quote Originally Posted by gue2013 View Post
    as long as only numbers changes and the text remains the same then remove the number with (change your data into a table)
    Please Login or Register  to view this content.
    Then you can easily sort or remove duplicates
    Thanks! It'd be great if you could elaborate a little about how the formula works? so I can replicate it for my data set as I don't quite understand it

  5. #5
    Registered User
    Join Date
    03-09-2020
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    15

    Re: Conditionally remove duplicate data

    Quote Originally Posted by jeffreybrown View Post
    Does this help? Use a couple of helper columns and then filter by column G to delete the dups. A value in column G greater than 1 means dup.
    Thanks! This definitely does help but the dataset I'm working on will have to be updated with new data every year or so. It'd be great if there was a formula/macro that could be replicated so when the next person updates it with new data, it's easy for them to delete duplicates rather than having to make another column etc.

  6. #6
    Valued Forum Contributor
    Join Date
    01-14-2013
    Location
    Austria
    MS-Off Ver
    2016 / 2019
    Posts
    339

    Re: Conditionally remove duplicate data

    First convert your data to a table (CTRL t) with headers

    then put this formula at the right side top of your data (you can change the heading later or before you add data)
    put the formula into this cell
    Please Login or Register  to view this content.
    three functions are used
    • right(input text, len) --> the output is the text with number of characters from the end of the input string
    • len(input strin) --> number of characters of the string
    • find( text to find, input string) --> text to find in input string


    [@[column name]] -- data in column

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Conditionally remove duplicate data

    Here's a macro to delete the dups. Please test on a copy of your data for testing purposes.

    Please Login or Register  to view this content.
    Paste code in a Normal module
    • Highlight macro to copy >> Ctrl + C >> Open your workbook
    • Alt + F11 >> opens the Visual Basic Editor (VBE)
    • Ctrl + R >>opens the Project Explorer (if not already open on left side of screen)
    • Insert menu >> Module or Alt + I, M >> activates the Insert menu and inserts a Standard Module
    • Paste code >> Ctrl + V (right side of screen)
    • Alt + Q >> exits VBE and returns to Excel
    • Back in Excel >> Alt + F8 >> Macro Dialog Box >> Highlight macro >> Run

    Note: Remember, any workbook with a macro must be saved as a workbook that can handle macros. .xlsm or .xlsb

  8. #8
    Registered User
    Join Date
    03-09-2020
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    15

    Re: Conditionally remove duplicate data

    Thanks very much, Jeff. I tried that but nothing happened?

    Btw the name of my actual sheets with this problem is "Goods X 2018 Eurostat" and "Goods M 2018 Eurostat" so I changed "Data" to the former.

    Also on the actual sheets the first country name and product starts in cell A12, B12 respectively.
    Last edited by jeffreybrown; 03-16-2020 at 12:17 PM. Reason: Please do not use full quotes!

  9. #9
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Conditionally remove duplicate data

    What exactly do you mean nothing happens?

    Did you by any chance try this macro on the workbook in post #2? Does that work?

    If your data looks different from post #1, can you post the a workbook as close to what you are working with?

+ 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: 04-26-2017, 08:01 PM
  2. Keeping Duplicate Data and Remove Everything Else
    By Kanook22 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-18-2014, 04:26 PM
  3. Remove the whole row when data duplicate
    By cherrychan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-20-2013, 07:05 PM
  4. [SOLVED] Sum data and remove duplicate rows
    By novice0281 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-05-2012, 06:17 AM
  5. How to Remove Both Sets of Duplicate Data
    By sstephen123 in forum Excel General
    Replies: 0
    Last Post: 11-10-2011, 09:27 AM
  6. Remove duplicate data from worksheet
    By dancinbean in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 07-15-2010, 12:02 PM

Tags for this Thread

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