look for duplicates in the same column loop

user125

New Member
Joined
Feb 20, 2020
Messages
31
Office Version
  1. 365
Platform
  1. Windows
Hello,

This might be a very simple solution but I just can't seem to get my head around it. Maybe one of you experts could help me out! :)

I am looking to create a loop where the code looks for duplicates in one column (in this case, column A) and if it is a duplicate, the cell next to it would say "duplicate" ("B4" and"B5"). I need to create a loop as there could be multiple cells to look for duplicates.

If you need more clarification, I would be more than happy to provide more information. Thanks in advance! :)

1583512291449.png
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Put this in B1 & copy down
=IF(COUNTIF(A$1:A1,A1)>1,"Duplicate","")
 
Upvote 0
Hello @Fluff ,

I was actually looking for VBA code that does this and not a formula. Would you be able to help me with the VBA code?

Thanks!
 
Upvote 0
Ok, how about
VBA Code:
Sub user125()
   With Range("B1:B" & Range("A" & Rows.Count).End(xlUp).Row)
      .Formula = "=if(countif(A$1:A1,A1)>1,""Duplicate"","""")"
      .Value = .Value
   End With
End Sub
 
Upvote 0
Ok, how about
VBA Code:
Sub user125()
   With Range("B1:B" & Range("A" & Rows.Count).End(xlUp).Row)
      .Formula = "=if(countif(A$1:A1,A1)>1,""Duplicate"","""")"
      .Value = .Value
   End With
End Sub

Thanks Fluff. That worked perfectly! :)
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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