+ Reply to Thread
Results 1 to 3 of 3

Check for previous entry

  1. #1
    Craig
    Guest

    Check for previous entry

    I am making a user form that inputs information on a worksheet, it will
    be making multiple entries for each row based on radio buttons on the
    form, the question i have is, is it possible to check a range of cells
    for a previous entry of the same value that the form is trying to put
    in the cell? Basically, i'm making a time sheet input that will enter
    the employee name in the A column then an in or out time (selected by
    radio buttons) in either B for in or C for out. I want to first search
    the previous entries of A for the employee to make sure i don't get two
    lines of the same employee. The employee name is being set by a combo
    box on the form. Any Suggestions?


  2. #2

    Re: Check for previous entry

    Craig, Try something like this:

    Private Sub CmdEnter_Click()

    Dim CurRng As Range

    For Each CurRng In Range("EmployeeNames")

    If CurRng = CboNames Then
    MsgBox "We Have an attempt at a duplicate entry in cell " _
    & CurRng.Address
    Exit For
    End If
    Next CurRng

    End Sub

    You can replace the MsgBox function with the code that you want to take
    it's place. By the way CboNames is the ComboBox name and
    Range("EmployeeNames") represents the area of the sheet where your
    names reside (Column A I guess) just in case you didn't get that. Hope
    that gets ya rollin... Mark


  3. #3
    Jim Cone
    Guest

    Re: Check for previous entry

    Craig,
    Something like this?
    NameButton is a button on the form.
    The TestForName sub can go in a standard module
    or in the Form module.
    Jim Cone
    San Francisco, USA


    '-----------------------------
    Private Sub NameButton_Click()
    TestForName
    End Sub

    Sub TestForName()
    Dim strValue As String
    strValue = UserForm1.ComboBox1.Value
    If IsError(Application.Match(strValue, Range("A1:A100"), 0)) Then
    MsgBox "Ok to use "
    Else
    MsgBox "Not ok to use "
    End If
    End Sub
    '-------------------------


    "Craig" <[email protected]>
    wrote in message
    news:[email protected]
    I am making a user form that inputs information on a worksheet, it will
    be making multiple entries for each row based on radio buttons on the
    form, the question i have is, is it possible to check a range of cells
    for a previous entry of the same value that the form is trying to put
    in the cell? Basically, i'm making a time sheet input that will enter
    the employee name in the A column then an in or out time (selected by
    radio buttons) in either B for in or C for out. I want to first search
    the previous entries of A for the employee to make sure i don't get two
    lines of the same employee. The employee name is being set by a combo
    box on the form. Any Suggestions?


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1