View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Group Highlighting

Hi,

It's always a good idea to ask the question you want the answer to in the
first place :)

try this to leave singletons uncoloured

Sub prime_Lending()
icolour = 3
Range("A1").Interior.ColorIndex = icolour
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set myrange = Range("A2:A" & lastrow)
For Each c In myrange
If c.Value = c.Offset(-1).Value Then
c.Interior.ColorIndex = icolour
ElseIf c.Value < c.Offset(-1).Value And c.Value < c.Offset(1).Value Then

Else
If c.Offset(-1).Interior.ColorIndex = 3 Then
icolour = 6
Else
icolour = 3
End If
c.Interior.ColorIndex = icolour
End If
Next
End Sub

Mike

"Dorian C. Chalom" wrote:

Beutiful!
Very close to what I need and I am sure it will work.
The only thing I think may be missing is there may not be a repeat of a
code....
456
456
456
789
234
234
234

789 is not a repeating number and so I want that untouched.
And I want to do the complete row not just the cell....

Thanks a bunch!

"Mike H" wrote in message
...
Hi,

I assume column A. Right click your sheet tab, view code and paste this in
and run it


Sub prime_Lending()
icolour = 3
Range("A1").Interior.ColorIndex = icolour
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set myrange = Range("A2:A" & lastrow)
For Each c In myrange
If c.Value = c.Offset(-1).Value Then
c.Interior.ColorIndex = icolour
Else
If c.Offset(-1).Interior.ColorIndex = 3 Then
icolour = 6
Else
icolour = 3
End If
c.Interior.ColorIndex = icolour
End If
Next
End Sub

Mike


"Dorian C. Chalom" wrote:

I have a spreadsheet of

123
123
123
456
456
456
789
234
234
234

I want 123 to be shaded one color
456 another color
and 234 the same color of 123
and go on that way
hieghtlighting the group of records alternatiing colors
How might I go about doing this?

Thank you...