+ Reply to Thread
Results 1 to 1 of 1

Prevent Duplicate Entries

  1. #1
    Registered User
    Join Date
    06-07-2007
    Posts
    9

    Prevent Duplicate Entries

    I have a workbook that I need to prevent duplicate entriesw in colum A I have worked out how to do this for data that is manually entred but need to do this for bulk data that is pasted in from another workbook
    The code that I am currently using is :

    Private Sub Workbook_SheetChange(ByVal Sh As Object, _
    ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    If Target.Column <> 1 Then Exit Sub
    Dim mySh As Worksheet
    Dim mySum As Integer
    mySum = 0
    For Each mySh In ThisWorkbook.Worksheets
    mySum = mySum + Application.CountIf(mySh.Range("A:A"), Target.Value)
    Next mySh
    If mySum > 1 Then
    MsgBox "Invoice Already Exists"
    With Application
    .EnableEvents = False
    If MsgBox("Do you want to Enter that anyway?", _
    vbYesNo) = vbNo Then
    .Undo
    End If
    .EnableEvents = True
    End With
    End If
    End Sub
    what do I need to change or add to either prevent or highligth duplicats that are pasted in to the workbook??
    Last edited by luckyphil; 06-12-2007 at 01:49 AM.

+ 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