+ Reply to Thread
Results 1 to 11 of 11

Highlight Rows of Duplicate results column with unique coloring

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

    Question Highlight Rows of Duplicate results column with unique coloring

    Hello,
    I have searched and tried various Macros but none are working for me - appreciate your help.

    My spreadsheet is A1:G1289 with Row 1 being header.
    Column F contains duplicate part numbers

    Objective: Identify duplicate values in column F (Any value in column F that is equal to another value in column F) and highlight those ROWS (groupings) with unique coloring.
    This spreadsheet will continue to grow so would like the maximum color spectrum available.

    Thanks in advance.
    Glen

    Excel 2013
    Last edited by G-Co; 07-20-2017 at 06:43 PM. Reason: Clarifying and correcting details

  2. #2
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Highlight Rows of Duplicate results column with unique coloring

    Hi, I'd just like to clarify what you mean by duplicate values and unique coloring. Do you mean;

    1) Any value that matches a specific reference value, or
    2) Any value in column F that is equal to another value in column F

    I'm guessing 2, so would you want each GROUP of duplicate numbers to be a different color?

    EDIT: Also, I'm assuming you meant row 1 is the header not column A?
    Last edited by danielexcelvba; 07-20-2017 at 04:13 PM.

  3. #3
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Highlight Rows of Duplicate results column with unique coloring

    Here's a way to do what I think you're asking
    Please Login or Register  to view this content.
    Note: people on here will likely give you much better solutions that avoid using Selection, this is just how I know how to do it. Also, some of the "Duplicate groups" will have a color index assigned to their background, but it will be white/light grey or some other hard to see color

  4. #4
    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

    Thank you, Daniel

    Sorry for any confusion in the initial details, and you are correct. It is the second option you clarified, that in column F there are values duplicate to others - creating "groups".
    And yes, "Row 1" (I'm working on little sleep at the moment).

    I will try your script shortly and let you know.
    Thanks again,
    Glen

  5. #5
    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 danielexcelvba View Post
    Here's a way to do what I think you're asking
    Please Login or Register  to view this content.
    Note: people on here will likely give you much better solutions that avoid using Selection, this is just how I know how to do it. Also, some of the "Duplicate groups" will have a color index assigned to their background, but it will be white/light grey or some other hard to see color
    Hello again, Daniel,
    I ran the script and it returned Run-time error '13': Type mismatch.
    (it also dropped into cell J2 a value of "1653666" ?)
    The Debug highlighted the issue here: If Cells(j, 6).Value <> Cells(i, 6).Value Then

    Glen

  6. #6
    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

    How would this be useful?

    regardless try this.

    Please Login or Register  to view this content.
    If you want something done right... find a forum and ask an online expert.

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

  7. #7
    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

  8. #8
    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.

    Please Login or Register  to view this content.
    "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.

  9. #9
    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.

    Please Login or Register  to view this content.
    "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

  10. #10
    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

    yes you have errors in your data.
    #N/A

    here is a lazy workaround but the obvious solution is to not have errors.
    also adjusted how the filter works to work with your data

    Please Login or Register  to view this content.

  11. #11
    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
    yes you have errors in your data.
    #N/A

    here is a lazy workaround but the obvious solution is to not have errors.
    also adjusted how the filter works to work with your data

    Please Login or Register  to view this content.
    This has totally solved it! Thank you Scottiex
    Yes, the errors are a result of a vlookup without data present. This will be an ever-present circumstance as the Item will either be present in one or both MCO's which are merged into this one sheet.
    Thanks for everyone's input and Scottiex ftw!

    Glen

+ 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