ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If duplicate in range (https://www.excelbanter.com/excel-programming/429907-if-duplicate-range.html)

Art

If duplicate in range
 
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

Jacob Skaria

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



All times are GMT +1. The time now is 11:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com