Results 1 to 2 of 2

Thread: Excel Duplicate Values

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    5

    Excel Duplicate Values

    Hi all,

    Code:
    Sub HighlightDuplicates()
        ' A & B are the columns which we hv to check the duplicate values
        Worksheets("sheet1").Range("A:B").Select
        ' conditional formatting code
        With Selection
            .FormatConditions.AddUniqueValues
            .FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
            .FormatConditions(1).DupeUnique = xlDuplicate
        End With
        With Selection.FormatConditions(1).Font
            .Color = vbRed
            .TintAndShade = 0
        End With
    End Sub
    Is this correct way to highlight the duplicate entries between the 2 columns

  2. #2
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: Excel Duplicate Values

    yes. It could be a bit simplified but its correct

    vb.net Code:
    1. With Worksheets("sheet1").Range("A:B")
    2.     .FormatConditions.AddUniqueValues
    3.     .FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    4.     .FormatConditions(1).DupeUnique = xlDuplicate
    5.     .FormatConditions(1).Font.Color = vbRed
    6. End With
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width