+ Reply to Thread
Results 1 to 14 of 14

Do until loop (deleting duplicate values)

  1. #1
    Registered User
    Join Date
    05-15-2012
    Location
    Guam
    MS-Off Ver
    2010
    Posts
    30

    Do until loop (deleting duplicate values)

    Hi,

    I have an excel sheet list that has duplicate values and want delete the duplicate value. After sorting the list, it looks like the following:

    aa 12
    aa 13
    bb 32
    bb 44
    cc 34
    cc 56

    I would like a macro to delete every other value or a smart macro that just deletes the duplicate value (i.e., the variable and not the information appended to the variable) and keeps one of them. After running the macro the new list should look like this:

    aa 12
    ......13
    bb 32
    .....44
    cc 34
    .....56

    The list can be as long as the row limitation of excel 2010 or as short as 10 rows.
    Last edited by buntalan80; 05-30-2012 at 10:51 PM.

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Do until loop (deleting duplicate values)

    assuming your values are all in one column (not aa in column A, 12 in column B) and the text and numbers are always separated by a space, this should work for all selected cells:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-15-2012
    Location
    Guam
    MS-Off Ver
    2010
    Posts
    30

    Re: Do until loop (deleting duplicate values)

    Hi,
    Thanks for replying. I should have been more specific. The variable populates one column and the values populate one or more columns.

  4. #4
    Registered User
    Join Date
    11-08-2006
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    37

    Re: Do until loop (deleting duplicate values)

    Assuming you want to clear values from the duplicate cells, the following code should do what you want. To execute, anchor should point to the first cell in the list.

    Please Login or Register  to view this content.
    Regards, AB

  5. #5
    Registered User
    Join Date
    05-15-2012
    Location
    Guam
    MS-Off Ver
    2010
    Posts
    30

    Re: Do until loop (deleting duplicate values)

    Hi aussieboykie,

    When I run it, I get a runtime error'424' object required and "With anchor.Cells(1)" is highlighted.

  6. #6
    Registered User
    Join Date
    11-08-2006
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    37

    Re: Do until loop (deleting duplicate values)

    Quote Originally Posted by buntalan80 View Post
    When I run it, I get a runtime error'424' object required and "With anchor.Cells(1)" is highlighted.
    Select the anchor cell (in your example that would be the first "aa" cell) then removedups anchor:=activecell or you can add a macro to do it..

    Please Login or Register  to view this content.
    Regards, AB

  7. #7
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Do until loop (deleting duplicate values)

    Can I confirm

    1) the result you're looking for is e.g. aa in column A, 12 in column B, 13 in columns C - ie all values where "aa" is on the left are placed on columns to the right of the aa.
    2) there is only ever one variable name and one value in each cell
    3) the variable and value are always separated by a space
    4) the variabel name "aa" is in a column adjacent to the value "12"

    it might be easier if you upload a spreadsheet with examples of the "before" and "after" you want
    Last edited by NickyC; 05-31-2012 at 12:06 AM.

  8. #8
    Registered User
    Join Date
    05-15-2012
    Location
    Guam
    MS-Off Ver
    2010
    Posts
    30

    Re: Do until loop (deleting duplicate values)

    Hi NickyC,

    I've attached a sample file to avoid confusion.
    Thanks again.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Do until loop (deleting duplicate values)

    ok, select the labels in column A and try this:

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    05-15-2012
    Location
    Guam
    MS-Off Ver
    2010
    Posts
    30

    Re: Do until loop (deleting duplicate values)

    Thank you.

  11. #11
    Registered User
    Join Date
    12-06-2011
    Location
    Japan
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Do until loop (deleting duplicate values)

    Hi,

    I've similar problem but the desired result is different.
    I've huge amount of data in multiple row and columns. The first column contains the unique data (Say Unique IDs) and are duplicated.
    Now I want to remove duplicates for unique IDs on the basis of some particular values in other column.
    For example, Column A is having unique IDs with duplicates and Column C is having values different values for each duplicate of particular IDs (Column A: 11,11,11 and Column C is : aa,bb,cc. I want Column A to contain unique 11 and column C say bb that I explicitly will mention)
    I hope I tried to explain my requirement.


    Thanks a lot in advance !




    Data

    112233 aa xyz mnc pqr
    112233 bb sdw sdf wer
    112233 cc aaa nma pre
    224431 rr aaq asa dsa
    224431 bb bsa sab nam
    224431 cc rrr www apq
    998873 aa ree tre uio
    998873 bb bre bte tre
    998873 rr bbnm bgy uyg
    123345 ww rty iuu oiu
    567654 pp try iuy opp
    345621 bb yuyt kjh hbh




    desired
    112233 bb sdw sdf wer
    224431 bb bsa sab nam
    998873 bb bre bte tre
    123345 ww rty iuu oiu
    567654 pp try iuy opp
    345621 bb yuyt kjh hbh

  12. #12
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Do until loop (deleting duplicate values)

    can you post an example?

  13. #13
    Registered User
    Join Date
    12-06-2011
    Location
    Japan
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Do until loop (deleting duplicate values)

    Hi,

    Thanks for taking interest and providing me the support!

    I tried to project the example of my requirement as below

    Data

    112233 aa xyz mnc pqr
    112233 bb sdw sdf wer
    112233 cc aaa nma pre
    224431 rr aaq asa dsa
    224431 bb bsa sab nam
    224431 cc rrr www apq
    998873 aa ree tre uio
    998873 bb bre bte tre
    998873 rr bbnm bgy uyg
    123345 ww rty iuu oiu
    567654 pp try iuy opp
    345621 bb yuyt kjh hbh

    The data is what exactly I'm having with duplicate (See Col A). they are unique values but they are repeated in excel sheet.
    I've to remove duplicate value of Col A based on the value Col B having. For example, somehow if I can put a condition that I want to keep all the unique values in Col A for value bb in Col B and delete all duplicates.

    Then my desired result will look like below.

    desired Result
    112233 bb sdw sdf wer
    224431 bb bsa sab nam
    998873 bb bre bte tre
    123345 ww rty iuu oiu
    567654 pp try iuy opp
    345621 bb yuyt kjh hbh

    Thanks in advance!

  14. #14
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Do until loop (deleting duplicate values)

    is your information contained in one column, 2 columns or a column for each string of letters
    how are you identifying which rows to keep and which to delete.
    For example, do you keep only rows including "bb"? what happens if a number has more than one row with "bb" or none at all

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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