View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
smandula smandula is offline
external usenet poster
 
Posts: 116
Default Edge Sequence Color

Could some bush up this vba? I need to color the edge of
the first cell. in a sequence of cells.

A B C D E
1 99 2 3 4 13
2 6 12 1 2 23

In the above example in row 1 -- 2&3&4 are in sequence thereby Cell B1
would have a yellow left hand edge colored.

Similarly, in row 2 -- 1&2 are in sequence thereby Cell C2
would have a yellow left hand edge colored

Sub ColorFirstEdgeSeq()
Dim x As Range
With Sheets("Sheet1")
Set x = .Range(.Range("A1"), .Range("E2"))
End With

For Each C In x
If C.Value = (C.Offset(0, 1).Value - 1) Then
Range(C, C.Offset(0, 1)).Select
With ActiveCell.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 36
End With

End If
Next

Range("A1").Select
End Sub

With Thanks
Steve