+ Reply to Thread
Results 1 to 2 of 2

How to avoid duplicates across multiple worsheets in excel?

  1. #1
    Lisa J
    Guest

    How to avoid duplicates across multiple worsheets in excel?

    Ho do I avoid making duplicate entries across a number of worksheets in the
    same spreadsheet? I can avoid duplicates on the same page by using the Data
    Validation function, but when I try to do this across more than one sheet I
    am not able to.

    Any help would be much appreciated.



  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Response

    You can use the following macro linked to the Workbook_SheetChange event on the ThisWorkbook tab.

    It's a bit slow and can be improved by restricting the search range to the cells that you are likely to use.

    e.g. Sheet.Range(Sheet.Cells(1, 1), Sheet.Cells(100, 100)) instead of Sheet.Cells



    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Dim DuplicatedValue As Boolean
    DuplicatedValue = False
    For Each Sheet In Sheets
    If Sheet Is Sh Then
    If Application.CountIf(Sheet.Cells, Target) > 1 Then
    DuplicatedValue = True
    End If
    Else
    If Application.CountIf(Sheet.Cells, Target) > 0 Then
    DuplicatedValue = True
    End If
    End If
    Next Sheet
    If DuplicatedValue = True Then MsgBox "Duplicate"

    End Sub
    Martin

+ 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