+ Reply to Thread
Results 1 to 2 of 2

Message box if cell is duplicate

Hybrid View

  1. #1
    Registered User
    Join Date
    10-21-2016
    Location
    Denver Co
    MS-Off Ver
    2013
    Posts
    65

    Message box if cell is duplicate

    is there a way of having the below statement to state if there are duplicated have a messgae box state" Duplicates Found"

    and if there are not

    "No Duplicates Found"
    
    
    Worksheets("Summary").Select
    
    '
        Columns("Z:Z").Select
        Selection.FormatConditions.AddUniqueValues
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        Selection.FormatConditions(1).DupeUnique = xlDuplicate
        With Selection.FormatConditions(1).Font
            .Color = -16751204
            .TintAndShade = 0
        End With
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 10284031
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = False
        
        MsgBox "Done"
    End Sub

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Message box if cell is duplicate

    Try this:

    Add sub below to your module and amend your sub
    replacing:
    MsgBox "Done"
    with:
    call AnyDuplicates
    Sub AnyDuplicates()
    
    Dim cel As Range, rng As Range
    Set rng = Range("Z1").Resize(Range("Z" & Cells.Rows.Count).End(xlUp).Row)
    
    For Each cel In rng
        If cel.Value <> "" And cel.Row <> WorksheetFunction.Match(cel.Value, rng, 0) Then
                MsgBox "Duplicate found": Exit Sub
        End If
    Next cel
    
    End Sub
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Find a duplicate number in cell range and displaying a message box.
    By jon124 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2017, 05:22 PM
  2. Duplicate within a single cell compared to other cell => error message
    By jokris in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-22-2016, 07:58 AM
  3. [SOLVED] Pop up message box if duplicate exist
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-23-2013, 10:59 AM
  4. Pop up Message for duplicate values in a column
    By mainroad in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2013, 01:10 PM
  5. Vba to display message when duplicate enteries are in the same row
    By Nicola13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2012, 05:48 AM
  6. Code to search for duplicate and pop up message asking for different value
    By Glensafro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-12-2012, 12:30 PM
  7. Message if duplicate found
    By WhiteKelso in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-26-2007, 11:36 PM

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