Prevent duplicate entry


Posted by Marc Duguay on April 18, 2001 8:09 PM

Hi,


First of all I would like to thank everybody that support this site, I think it’s a great source of
Informations for a rookie like my self and many others. BRAVO !!!


Now down to business this is what I am trying to accomplish.

Sub CommandButton1_Click()

Worksheets("sheet1").Range("C10") = UserForm1.TextBox1.Value

If Sheets("sheet1").Range("C10") = Sheets("sheet1").Range("A:A") Then

UserForm2.Show

Unload Me
End If
Sheets("Sheet1").Select
Range("C10").Select
Selection.Copy
Range("A30").Select
ActiveSheet.Paste

Unload Me

End Sub


I want the value of “ C10”(part number) to look in column “A “ and see if the
Part numbers already exist.

This reference is my problem { If Sheets("sheet1").Range("C10") = Sheets("sheet1").Range("A:A") Then}
If I use a single cell as reference it works exactly how I want it to, but as soon as
I try to to use column “A” as a reference I get that familiar Debug box I think
I have seen that dam box 1000000 time.

So please any help would be greatly appreciated

Thank you,
Marc

Posted by Dave Hawley on April 18, 2001 8:28 PM

Hi Marc

Give this a try.

Sub CommandButton1_Click()
Dim STextbox1 As String
Dim SCellC1 As String

STextbox1 = UserForm1.TextBox1.Value
Worksheets("sheet1").Range("C10") = STextbox1

If WorksheetFunction.CountIf _
(Sheets("sheet1").Range("A:A"), _
STextbox1) <> 0 Then

UserForm2.Show

Unload Me
End If
Sheets("Sheet1").Range("A30") = STextbox1
Application.CutCopyMode = False
Unload Me

End Sub

Dave
OzGrid Business Applications

Posted by Dave Hawley on April 18, 2001 8:28 PM

Hi Marc

Give this a try.

Sub CommandButton1_Click()
Dim STextbox1 As String
Dim SCellC1 As String

STextbox1 = UserForm1.TextBox1.Value
Worksheets("sheet1").Range("C10") = STextbox1

If WorksheetFunction.CountIf _
(Sheets("sheet1").Range("A:A"), _
STextbox1) <> 0 Then

UserForm2.Show

Unload Me
End If
Sheets("Sheet1").Range("A30") = STextbox1
Unload Me

End Sub

Dave
OzGrid Business Applications



Posted by Marc Duguay on April 18, 2001 8:35 PM

Thank you Dave You are an Excel Master !!!!

Yahoooooo !!!