VBA to highlight cells
Of course i meant
If Cells(i, 2).Value = Cells(i, 2).Offset(-1, 0).Value Then
:)
Mike
"Mike H" wrote:
Try,
Sub bandit()
icolour = 3
lastrow = Range("b65536").End(xlUp).Row
Cells(1, 2).Select
ActiveCell.EntireRow.Select
Selection.Interior.ColorIndex = icolour
For i = 2 To lastrow
Cells(i, 2).Select
If Cells(i, 2).Value = Cells(i, 2).Offset(1, 0).Value Then
ActiveCell.EntireRow.Select
Selection.Interior.ColorIndex = icolour
Else
icolour = icolour + 1
ActiveCell.EntireRow.Select
Selection.Interior.ColorIndex = icolour
End If
Next
End Sub
Mike
"Amcdee" wrote:
Hi folks,
hope you can help with a little problem. The has to be achieved using
VBA so please don't suggest conditional formatting as it wont achieve
what is required.
we have a sheet in the following format:
A B C D
101 10A "Some String" "Some String"
101 10A "Some String" "Some String"
101 50A "Some String" "Some String"
303 50A "Some String"
303 50A "Some String" "Some String"
303 1152A "Some String" "Some String"
Ok here is the problem... we wish to highlight (color) the background
of each row that has identical vales in column B. The sheet auto
updates from a data source, and is sorted on the values in column B,
therefore all identical values will remain together.
Any help would be appreciated as this is driving me mad.
Many thanks in advance
|