View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default If duplicate in range

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
---------------
Jacob Skaria


"art" wrote:

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