+ Reply to Thread
Results 1 to 4 of 4

List to manage employee code

  1. #1
    Tahani
    Guest

    List to manage employee code

    I'm making a list of employee info , i want to do the following :
    Whenever i enter a value in a cell of employee code feild , excel checks if
    it is duplicated or not , if yes display an error message "Value duplicated "
    or any action to reject the inserted value, if no the new value is accepted

    Thank you

  2. #2
    Bob Phillips
    Guest

    Re: List to manage employee code

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim nFound As Long

    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range("A1:A100")) Is Nothing Then
    With Target
    If Application.CountIf(Me.Range("A1:A100"), .Value) > 1 Then
    MsgBox .Value & " is duplicate"
    .Value = ""
    End If
    End With
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub

    'This is worksheet event code, which means that it needs to be
    'placed in the appropriate worksheet code module, not a standard
    'code module. To do this, right-click on the sheet tab, select
    'the View Code option from the menu, and paste the code in.





    --
    HTH

    Bob Phillips

    "Tahani" <[email protected]> wrote in message
    news:[email protected]...
    > I'm making a list of employee info , i want to do the following :
    > Whenever i enter a value in a cell of employee code feild , excel checks

    if
    > it is duplicated or not , if yes display an error message "Value

    duplicated "
    > or any action to reject the inserted value, if no the new value is

    accepted
    >
    > Thank you




  3. #3
    DM Unseen
    Guest

    Re: List to manage employee code

    Use Data Validation.

    see http://www.j-walk.com/ss/excel/usertips/tip027.htm

    DM Unseen


  4. #4
    Tahani
    Guest

    Re: List to manage employee code

    Thank you very much
    Appreciate your help

    "Bob Phillips" wrote:

    > Private Sub Worksheet_Change(ByVal Target As Range)
    > Dim nFound As Long
    >
    > On Error GoTo ws_exit:
    > Application.EnableEvents = False
    > If Not Intersect(Target, Me.Range("A1:A100")) Is Nothing Then
    > With Target
    > If Application.CountIf(Me.Range("A1:A100"), .Value) > 1 Then
    > MsgBox .Value & " is duplicate"
    > .Value = ""
    > End If
    > End With
    > End If
    >
    > ws_exit:
    > Application.EnableEvents = True
    > End Sub
    >
    > 'This is worksheet event code, which means that it needs to be
    > 'placed in the appropriate worksheet code module, not a standard
    > 'code module. To do this, right-click on the sheet tab, select
    > 'the View Code option from the menu, and paste the code in.
    >
    >
    >
    >
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "Tahani" <[email protected]> wrote in message
    > news:[email protected]...
    > > I'm making a list of employee info , i want to do the following :
    > > Whenever i enter a value in a cell of employee code feild , excel checks

    > if
    > > it is duplicated or not , if yes display an error message "Value

    > duplicated "
    > > or any action to reject the inserted value, if no the new value is

    > accepted
    > >
    > > Thank you

    >
    >
    >


+ 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