PDA

View Full Version : Solved: Check fur duplicate entries



lanhao
07-26-2006, 01:34 PM
Hi there,

I have a form that I am trying to put togehter, adn one of hte things that needs to be included is a little string of code where it will check the list of information, and if it finds a duplicate name, it will popup a msgbox, and stop the userform from putting in the new data. (I'm going to be making a different form for editting existing data).

That's the code I have put together thinking it would work, but it doesn't seem to be registering this function before putting all the info in.


Dim v As Integer

v = 1
For v = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If tbNode.Value = ws.Range("A" & v) Then
MsgBox "This node has already been entered"
End If

Next v

Thanks for the help on this

Bob Phillips
07-26-2006, 03:57 PM
Try this



Dim v As Integer

With ws
For v = 1 To .Cells(.Rows.Count, "A").End(xlUp).Row
If tbNode.Value = .Cells(v, "A") Then
MsgBox "This node has already been entered"
Exit For
End If
Next v
End With

lanhao
07-27-2006, 07:06 AM
As usual, you're a genius. Thanks so much for helping me get that sorted out, and I incorporated it into the one other set of code.

I was close though, that actually makes me happy since it means I am getting the hang of this stuff. :)

Bob Phillips
07-27-2006, 11:23 AM
Yeah, you just seemed to lose track of what objects were what, and therefore which to extract the properties from.