code to check data for dupes and remove

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,604
Office Version
  1. 365
Platform
  1. Windows
Hi all

My sheet has data in columns ABC thru to line 21000

Can somebody help with code that will check each value thru column A and if any dupes are fould remove that row

for example if A25 shows THE VALUE '512' and it is already shown in A12 then delete row 25, loop until all rows have been checked

result would be aprox 100 rows of unique data where the value in column A is unique.

any help appreciated

many thanks
 
Last edited:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
=COUNTIF($A$1:A1,A1)

copied through your range, will return the number of times a duplicate is found in col A. Simply filter for values>1 and delete those rows. No need for VBA


Alternatively, Pivot Tables and Advanced Filter will produce lists of unique values.
 
Upvote 0
Hi redspanna,

i guess you can use the following code....

Sub removeduplicates()
k = Application.WorksheetFunction.CountA(ActiveSheet.Range("A:A"))
Columns("A:C").Select
ActiveSheet.Range("$A$1:$C$" & k).removeduplicates Columns:=1, Header:=xlNo
End Sub

I have made the folowing assumptions.
1. your data is starting from A1
2. there are no blanks in between.
3. there are no headers. ( if there is a header use Header:=xlYes in place of Header:=xlNo)
4. " if A25 shows THE VALUE '512' and it is already shown in A12 then delete row 25" so remove entire riow if a has duplicates...


hope i could help...
 
Upvote 0
Thank you both so much, both solutions worked :)

regards
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,135
Members
452,890
Latest member
Nikhil Ramesh

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