VBA checking for duplicates in a column

atblack22

New Member
Joined
Jun 16, 2011
Messages
10
I have a sheet setup in excel and in column A I have values listed down an undetermined number of rows and there are blank rows inbetween the cells that have data. I need to develop a VBA code that will check for duplicates in this entire column.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
I need it to identify duplicates, but not remove them. or if thats not possible, just to say there are duplicates, and review.
 
Upvote 0
I could, but I don't want to add that whole extra column of data in for users. I currently have this formula in cell F2 = =IF(COUNTA(A:A)=SUMPRODUCT((A:A<>"")/COUNTIF(A:A,A:A&"")),"No Duplicates","Duplicates")

Then I have a button that executes the next step in the process and it checks the cell value and if its duplicate it stops the process, and if its No Duplicate, then it moves to the next step, but I have a few more subprocesses within that macro that with this execution, it makes the cell fromula recalculate each time and slows down processing, so i want to eliminate.
 
Upvote 0
Hi
Try :
Code:
Sub test()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
    If Range("A" & i).Value = Range("A" & i - 1).Value Then Range("A" & i).Font.ColorIndex = 3
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,445
Members
452,915
Latest member
hannnahheileen

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