Delete duplicates cells

MayHmne

New Member
Joined
Sep 3, 2020
Messages
26
Office Version
  1. 2019
Platform
  1. Windows
I have tried the below macro and it is working but when applying it on a larger range of data (specifically 17137 rows) a considerable amount of data are deleted not just the duplicates

RemoveDupes add blank
Sub RemoveDupes()
Dim X As Long
For X = 1 To Range("A" & Rows.Count).End(xlUp).Row
If Application.WorksheetFunction.CountIf(Range("A1:A" & X), Range("A" & X).Text) > 1 Then Rows(X).ClearContents
Next
End Sub

so, any other codes that solve this issue?
Untitled.png
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
VBA Code:
Option Explicit

Sub DeleteRows()
Dim Rng As Range
    With ActiveSheet
        Set Rng = Range("A1").End(xlDown)
        Rng.RemoveDuplicates Columns:=1, Header:=xlNo
    End With

End Sub

See if this works.
 
Upvote 0
Try saving the workbook,, close it. Then re-open and run.
 
Upvote 0
a considerable amount of data are deleted not just the duplicates
Can you provide more detail about what is deleted that shouldn't be and where that data was?

Could you also provide your sample data and expected results with XL2BB so that we can see more exactly what you have and where it is & we can also then copy it for testing?
 
Upvote 0
Can you provide more detail about what is deleted that shouldn't be and where that data was?

Could you also provide your sample data and expected results with XL2BB so that we can see more exactly what you have and where it is & we can also then copy it for testing?
The list contains family members and I should delete the duplicated rows but it turns out that the list has the other families having the same names of members so, excel considers it duplicated. but I solved the problem
Thank you
 
Upvote 0
The macro is designed to check column A : Range("A1")

If you are checking a different column for the duplicates, change the A to the other column letter.
 
Upvote 0
The macro is designed to check column A : Range("A1")
I got a different error to the OP but since your rng will just be a single cell, I'm not surprised that it didn't act as expected.
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,217
Members
453,024
Latest member
Wingit77

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