Duplicate whole row

zubair009

New Member
Joined
Sep 8, 2012
Messages
27
https://app.box.com/s/lj3y3wcdr1ru1k2kvav2

Hi,
I have this data in 500 rows I want to border color with difference random color row wise i am also trying in vba but could not do it. if i select row from A TO F and then start macro it should color all smilir rows with one color and if row does not have smilar row then only one color.

Thank you so much if you can solve my problem.

regards
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Try:

Code:
Sub ColourDuplicates()
    Dim Rng As Range
    Dim Colour As Long
    Dim Formula1 As String
    Dim r As Long
    Dim c As Long
    Dim CountOne As Long
    Dim Formula2 As String
    Dim First As Long
    Set Rng = Range("C3").CurrentRegion
    Rng.Interior.ColorIndex = xlNone
    Colour = 3
    With Rng
        For r = 1 To .Rows.Count
            Formula1 = ""
            For c = 1 To .Columns.Count
                Formula1 = Formula1 & .Columns(c).Resize(r).Address & "," & .Cells(r, c).Address & ","
            Next c
            Formula1 = "=COUNTIFS(" & Left(Formula1, Len(Formula1) - 1) & ")"
            CountOne = .Parent.Evaluate(Formula1)
            If CountOne = 1 Then
                .Rows(r).Interior.ColorIndex = Colour
                Colour = Colour + 1
            Else
                Formula2 = ""
                For c = 1 To .Columns.Count
                    Formula2 = Formula2 & "(" & .Columns(c).Address & "=" & .Cells(r, c).Address & ")*"
                Next c
                Formula2 = "=MATCH(1,(" & Left(Formula2, Len(Formula2) - 1) & "),FALSE)"
                First = .Parent.Evaluate(Formula2)
                .Rows(r).Interior.ColorIndex = .Cells(First, 1).Interior.ColorIndex
            End If
        Next r
    End With
End Sub
 

zubair009

New Member
Joined
Sep 8, 2012
Messages
27
I love it, you are a super star since three months I am trying to do this but could not do this, I have tried to do it in my dream but even though I failed to do it.

Thank you mate. I am very very exited. you have made my weekend. Wish you all the best. GOD BLESS YOU. regards
 

Watch MrExcel Video

Forum statistics

Threads
1,129,752
Messages
5,638,157
Members
417,011
Latest member
Amaden95

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top