+ Reply to Thread
Results 1 to 11 of 11

Highlight Rows of Duplicate results column with unique coloring

Hybrid View

  1. #1
    Registered User
    Join Date
    07-20-2017
    Location
    Canada
    MS-Off Ver
    13
    Posts
    6

    Re: Highlight Rows of Duplicate results column with unique coloring

    Quote Originally Posted by scottiex View Post
    How would this be useful?

    regardless try this.

    ...
    End Sub[/CODE]
    Scottiex, thanks for the attempt but it resulted in the last record in a group being highlighted, and after about 20 lines every line was highlighted irrespective of duplicate values.
    To answer your question, this is useful as we are merging two data sets from different MCOs which share services and part numbers. We need to easily identify where a service and part number repeated for audit purposes.

    This morning I found the following script which is very close to what I want but it is looking duplicates in column A not F. I'm not sure how to alter it in this regard.

    Sub HighlightUniqueDuplicatesGC()
    Dim sh As Worksheet, c As Range, clr As Variant, lr As Long
    Set sh = ActiveSheet
    lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
    clr = Array(3, 4, 6, 7, 8, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 26, 27, 28, 31, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 53, 54)
    With sh
    .Range("A1:A" & lr).AdvancedFilter xlFilterCopy, , .Range("B" & lr + 2), True
    x = LBound(clr)
    For Each c In .Range("B" & lr + 4).CurrentRegion
    .UsedRange.AutoFilter 1, c.Value
    If Application.CountIf(.Range("A:A"), c.Value) > 1 Then
    .Range("A2", .Cells(Rows.Count, 1).End(xlUp)).SpecialCells(xlCellTypeVisible).EntireRow.Interior.ColorIndex = clr(x)
    End If
    .AutoFilterMode = False
    x = x + 1
    If x > UBound(clr) Then x = LBound(clr)
    Next
    .Range("B" & lr + 2).CurrentRegion.Delete
    End With
    End Sub

  2. #2
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Re: Highlight Rows of Duplicate results column with unique coloring

    OK seems I misunderstood your requirement.

    messy coding but here is a quick fix that seems to work... I see they limited the colours presumably to retain contrast.

    Sub HighlightUniqueDuplicatesGC()
    Dim sh As Worksheet, c As Range, clr As Variant, lr As Long
    Set sh = ActiveSheet
    lr = sh.Cells(Rows.Count, 6).End(xlUp).Row
    clr = Array(3, 4, 6, 7, 8, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 26, 27, 28, 31, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 53, 54)
    With sh
    .Range("F1:F" & lr).AdvancedFilter xlFilterCopy, , .Range("EE" & lr + 2), True
    x = LBound(clr)
    For Each c In .Range("EE" & lr + 4).CurrentRegion
    .UsedRange.AutoFilter 1, c.Value
    If Application.CountIf(.Range("F:F"), c.Value) > 1 Then
    .Range("F2", .Cells(Rows.Count, 6).End(xlUp)).SpecialCells(xlCellTypeVisible).EntireRow.Interior.ColorIndex = clr(x)
    End If
    .AutoFilterMode = False
    x = x + 1
    If x > UBound(clr) Then x = LBound(clr)
    Next
    .Range("EE" & lr + 2).CurrentRegion.Delete
    End With
    End Sub
    "To answer your question, this is useful as we are merging two data sets from different MCOs which share services and part numbers. We need to easily identify where a service and part number repeated for audit purposes."

    I see why they would ask for that, I sometimes get asked for that sort of thing. But there should be a better way. I presume once they find a duplicate they take some action and I imagine having a helper column with some indicator of what to do would be more useful.
    If you want something done right... find a forum and ask an online expert.

    Time flies like an arrow. Fruit flies like a banana.

  3. #3
    Registered User
    Join Date
    07-20-2017
    Location
    Canada
    MS-Off Ver
    13
    Posts
    6

    Re: Highlight Rows of Duplicate results column with unique coloring

    Quote Originally Posted by scottiex View Post
    OK seems I misunderstood your requirement.

    messy coding but here is a quick fix that seems to work... I see they limited the colours presumably to retain contrast.

    Sub HighlightUniqueDuplicatesGC()
    Dim sh As Worksheet, c As Range, clr As Variant, lr As Long
    Set sh = ActiveSheet
    lr = sh.Cells(Rows.Count, 6).End(xlUp).Row
    clr = Array(3, 4, 6, 7, 8, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 26, 27, 28, 31, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 53, 54)
    With sh
    .Range("F1:F" & lr).AdvancedFilter xlFilterCopy, , .Range("EE" & lr + 2), True
    x = LBound(clr)
    For Each c In .Range("EE" & lr + 4).CurrentRegion
    .UsedRange.AutoFilter 1, c.Value
    If Application.CountIf(.Range("F:F"), c.Value) > 1 Then
    .Range("F2", .Cells(Rows.Count, 6).End(xlUp)).SpecialCells(xlCellTypeVisible).EntireRow.Interior.ColorIndex = clr(x)
    End If
    .AutoFilterMode = False
    x = x + 1
    If x > UBound(clr) Then x = LBound(clr)
    Next
    .Range("EE" & lr + 2).CurrentRegion.Delete
    End With
    End Sub
    "To answer your question, this is useful as we are merging two data sets from different MCOs which share services and part numbers. We need to easily identify where a service and part number repeated for audit purposes."

    I see why they would ask for that, I sometimes get asked for that sort of thing. But there should be a better way. I presume once they find a duplicate they take some action and I imagine having a helper column with some indicator of what to do would be more useful.
    Thanks for the followup Scottiex.
    I ran the new code but it yielded a runtime error. I tried pre-selecting (highlighting) the range before running the code as well, to see if that would limit but same error.
    I am attaching an excerpt of sample data which I have manually highlighted lines to what I am hoping the end result would be (again, based on column F being duplicate. more obvious in the last records).
    Thanks again.
    Attached Files Attached Files

+ 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. Highlight duplicate two column and two column unique value
    By mahmudayaz in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 01-26-2017, 02:58 AM
  2. [SOLVED] Highlight duplicate rows excluding column and vice versa another column
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-07-2016, 02:22 PM
  3. highlight duplicate rows and delete based on highest value from column
    By adnan5586 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-10-2015, 02:05 AM
  4. [SOLVED] Need a macro to highlight Rows that contain a duplicate for each column of a data range
    By MoHassan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-22-2013, 05:39 AM
  5. Highlight duplicate rows based on column A but be case sensitive
    By theblade24 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-18-2013, 06:14 PM
  6. Highlight duplicate rows without helper column
    By tone640 in forum Excel General
    Replies: 5
    Last Post: 08-23-2011, 08:21 AM
  7. Replies: 0
    Last Post: 07-22-2011, 12:11 PM

Tags for this Thread

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