Consulting

Results 1 to 4 of 4

Thread: Solved: Check fur duplicate entries

  1. #1

    Solved: Check fur duplicate entries

    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.

    [VBA]
    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 [/VBA]

    Thanks for the help on this
    Heaven won't take me.. Hell is afraid I'll take over... adn Purgatory doesn't have a smoking section... I am SO screwed...

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try this

    [vba]

    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
    [/vba]

  3. #3
    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.
    Heaven won't take me.. Hell is afraid I'll take over... adn Purgatory doesn't have a smoking section... I am SO screwed...

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Yeah, you just seemed to lose track of what objects were what, and therefore which to extract the properties from.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •