+ Reply to Thread
Results 1 to 2 of 2

Message box to pop up when duplicate values are in a column a

Hybrid View

  1. #1
    Registered User
    Join Date
    02-24-2013
    Location
    napier nz
    MS-Off Ver
    Excel 2010
    Posts
    11

    Cool Message box to pop up when duplicate values are in a column a

    Hi

    I am after a routine to add into a macro that displays a message box if duplicate data is in say - column A.

    the important aspect is that I am copying and pasting data from another file into sheet1 - hence data validation doesnt seem to work.

    i need an independent macro i can tack on or run independently not a none built into sheet1

    thanks for your help.

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Message box to pop up when duplicate values are in a column a

    Dunno about a popup because you may have multiple duplicates so it could get a bit boring..

    The following uses conditional highlighting to show duplicates

    Sub HighlightDupes()
    Dim LastRow As Long
        Range("A1").Select
        LastRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
        Range("$A$1:$A" & LastRow).FormatConditions.Delete
        Range("$A$1:$A" & LastRow).FormatConditions.Add Type:=xlExpression, Formula1:= _
            "=COUNTIF($A2:$A$" & LastRow & ",A1)>0"
        Range("$A$1:$A" & LastRow).FormatConditions(Range("$A$1:$A" & LastRow).FormatConditions.Count).SetFirstPriority
        With Range("$A$1:$A" & LastRow).FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 5287936
            .TintAndShade = 0
        End With
        Range("$A$1:$A" & LastRow).FormatConditions(1).StopIfTrue = False
    End Sub
    Note ; If the duplicates are a pair - it only highlights the first instance
    Elegant Simplicity............. Not Always

+ 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