VBA to highlight cells

A

amcdee

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
 
G

Gary''s Student

try:

Sub shade_it()
n = Cells(Rows.Count, 2).End(xlUp).Row
For i = 1 To n
If Application.WorksheetFunction.CountIf(Range("B:B"), Cells(i,
2).Value) > 1 Then
Cells(i, 2).EntireRow.Interior.ColorIndex = 6
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top