Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Color duplicates
Hello,
I want Excel to color duplicates in different color and each set of duplicates have same color. I found this macro, but it does not highlight the set of duplicates in same color. Private Sub Worksheet_Change(ByVal Target As Range) Dim cell As Range Dim rng As Range Set rng = Range("A1:A100") Application.EnableEvents = False On Error GoTo sub_exit If Not Intersect(Target, rng) Is Nothing Then With Target For Each cell In rng If WorksheetFunction.CountIf(rng, cell) 1 Then cell.Interior.ColorIndex = Int(Rnd(1) * 56) + 1 End If Next cell End With End If sub_exit: Application.EnableEvents = True End Sub Any Help? Thx. -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...excel/200710/1 |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Color duplicates
Change the one line
cell.Interior.ColorIndex = Int(Rnd(1) * 56) + 1\ to this for red cell.Interior.ColorIndex = 3 Gord Dibben MS Excel MVP On Fri, 19 Oct 2007 17:49:57 GMT, "saman110 via OfficeKB.com" <u35670@uwe wrote: Hello, I want Excel to color duplicates in different color and each set of duplicates have same color. I found this macro, but it does not highlight the set of duplicates in same color. Private Sub Worksheet_Change(ByVal Target As Range) Dim cell As Range Dim rng As Range Set rng = Range("A1:A100") Application.EnableEvents = False On Error GoTo sub_exit If Not Intersect(Target, rng) Is Nothing Then With Target For Each cell In rng If WorksheetFunction.CountIf(rng, cell) 1 Then cell.Interior.ColorIndex = Int(Rnd(1) * 56) + 1 End If Next cell End With End If sub_exit: Application.EnableEvents = True End Sub Any Help? Thx. |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Color duplicates
Ignore this, it will change all cells to red. Not what you wanted.
Gord On Fri, 19 Oct 2007 15:24:36 -0700, Gord Dibben <gorddibbATshawDOTca wrote: Change the one line cell.Interior.ColorIndex = Int(Rnd(1) * 56) + 1\ to this for red cell.Interior.ColorIndex = 3 Gord Dibben MS Excel MVP On Fri, 19 Oct 2007 17:49:57 GMT, "saman110 via OfficeKB.com" <u35670@uwe wrote: Hello, I want Excel to color duplicates in different color and each set of duplicates have same color. I found this macro, but it does not highlight the set of duplicates in same color. Private Sub Worksheet_Change(ByVal Target As Range) Dim cell As Range Dim rng As Range Set rng = Range("A1:A100") Application.EnableEvents = False On Error GoTo sub_exit If Not Intersect(Target, rng) Is Nothing Then With Target For Each cell In rng If WorksheetFunction.CountIf(rng, cell) 1 Then cell.Interior.ColorIndex = Int(Rnd(1) * 56) + 1 End If Next cell End With End If sub_exit: Application.EnableEvents = True End Sub Any Help? Thx. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can't format cell color/text color in Office Excel 2003 in fil | Excel Discussion (Misc queries) | |||
Need to Color Record in Duplicates | Excel Worksheet Functions | |||
Can't format cell color/text color in Office Excel 2003 in files . | Excel Discussion (Misc queries) | |||
Excel 2003 will not display color fonts or color fill cells | Excel Worksheet Functions | |||
My excel 2003 wont let me fill cells with color or color the tabs. | New Users to Excel |