If duplicate in range

  • Thread starter Thread starter art
  • Start date Start date
A

art

Hello:

I have a range from A1:A50. I would like to have a code that if I enter an
amount in a cell that is already included in another cell, then it should not
let me, or notify me with msgbox.

Thanks so much.

Art
 
You can use the Worksheet function COUNTIF() to check..

Sub Macro()
intNum = 50
If WorksheetFunction.CountIf(Range("A1:A50"), intNum) > 0 Then
MsgBox "Number already exist": Exit Sub
End If

End Sub

If this post helps click Yes
 
Back
Top