Remove duplicates function will not work -

dimleyk

New Member
Joined
Jan 20, 2014
Messages
1
Hello guys
This is my first post here, but i went over previous posts searching for assistance with the following issue:
I need to remove duplicate values and leave only unique values. Remove duplicates function in Execl2010 is stating that no duplicates were found, although the selected data were correctly identified, and no spaces existed in different cells - i used func. LEN to verify this.
The example data looks like the following:

Col1Col2Col3Col4Col5
Row1ahe'ssinceanybodhed
Row2abouthighlysinglanyonehe'd
Row3abovehimsixafterher
Row4absolutelyhimselfsoeverybodhers
Row5acrosshisaftereveryoneherself
Row6actuallyhopefullysomebodeverythinghes
Row7afterhowsomehowhedhis
Row8againhoweversomeonehe'dhim
Row9againsthundredsomethingheragain

<tbody>
</tbody>

xlsx version available here: https://dl.dropboxusercontent.com/u/57324527/dupblic1.xlsx

duplic.PNG


Thank you for all those who are familiar with such questions and are willing to help

Thanks! ;)

<tbody>
</tbody>
 
Last edited:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
You are right, I can not remove them on my Excel 2010, ir runs only if I select one column
 
Upvote 0
Hi, dimleyk,

I wonder what items should be removed as duplicates as I may only find unique values.

Ciao,
Holger
 
Upvote 0
Hi, dimleyk,

I wonder what items should be removed as duplicates as I may only find unique values.

Ciao,
Holger

There are at least five duplicates in that chart.

To the OP, ensure there are no spaces at the end of your data as Excel will not recognize these as duplicates. Occasionally this will happen to me if I drag or copy data from one cell to another, for some reason it will not recognize it immediately, and I'm forced to manually type it in and then reformat that column or the entire sheet and they will then be highlighted. I don't know if this helps, but it is what I do.
 
Upvote 0
dimleyk,

If this is what your raw data looks like:


Excel 2007
ABCDE
1ahe'ssinceanybodhed
2abouthighlysinglanyonehe'd
3abovehimsixafterher
4absolutelyhimselfsoeverybodhers
5acrosshisaftereveryoneherself
6actuallyhopefullysomebodeverythinghes
7afterhowsomehowhedhis
8againhoweversomeonehe'dhim
9againsthundredsomethingheragain
10
Sheet1


Is this what the results should look like?


Excel 2007
ABCDE
1ahe'ssinceanybod
2abouthighlysinglanyone
3abovesix
4absolutelyhimselfsoeverybodhers
5acrosseveryoneherself
6actuallyhopefullysomebodeverythinghes
7howsomehow
8howeversomeone
9againsthundredsomething
10
Sheet1
 
Upvote 0
dimleyk,

Welcome to the MrExcel forum.

Sample raw data:


Excel 2007
ABCDE
1ahe'ssinceanybodhed
2abouthighlysinglanyonehe'd
3abovehimsixafterher
4absolutelyhimselfsoeverybodhers
5acrosshisaftereveryoneherself
6actuallyhopefullysomebodeverythinghes
7afterhowsomehowhedhis
8againhoweversomeonehe'dhim
9againsthundredsomethingheragain
10
Sheet1


After the macro:/b]


Excel 2007
ABCDE
1ahe'ssinceanybod
2abouthighlysinglanyone
3abovesix
4absolutelyhimselfsoeverybodhers
5acrosseveryoneherself
6actuallyhopefullysomebodeverythinghes
7howsomehow
8howeversomeone
9againsthundredsomething
10
Sheet1


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Option Explicit
Sub RemoveAllDupes()
' hiker95, 01/24/2014, ME751650
Dim lr As Long, lc As Long
Dim rng As Range, c As Range, frng As Range
Dim n As Long, i As Long, h As String
Application.ScreenUpdating = False
lr = Cells(Rows.Count, 1).End(xlUp).Row
lc = Cells(1, Columns.Count).End(xlToLeft).Column
Set rng = Range(Cells(1, 1), Cells(lr, lc))
With rng
  .Value = Evaluate("IF(ISTEXT(" & .Address & "),TRIM(" & .Address & "),REPT(" & .Address & ",1))")
End With
For Each c In rng
  If c <> "" Then
    n = Application.CountIf(rng, c)
    If n > 1 Then
      h = c
      c = ""
      For i = 2 To n
        Set frng = rng.Find(h, LookAt:=xlWhole)
        If Not frng Is Nothing Then
          Cells(frng.Row, frng.Column) = ""
        End If
      Next i
    End If
  End If
Next c
Application.ScreenUpdating = True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm

Then run the RemoveAllDupes macro.
 
Upvote 0
Hi, loletters,

we as humans understand a different thing about Duplicates as does Excel. In Excel this tool has been present as part of the Advanced Filter ever since introduced. Two things need to stay in memory: the Advanced Filter will only work on single columns to be compared and will always have an effect on the row in which Excel recognizes a duplicate.

The feature which was introduced from Excel2007 on does the same so there really is no way to use this to recognise duplicates in a range or just delete contents for single cells (it will always influence the rows if a comparision on a column found a match). hiker95 provided a macro which does exactly what the tool from Excel can´t deliver.

Ciao,
Holger
 
Upvote 0
HaHoBe,

Even though dimleyk has marked their thread with an "Unhappy" indicator in the title.

hiker95 provided a macro which does exactly what the tool from Excel can´t deliver.

Thanks for that, and, have a great day.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,831
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top