Hi akrosita2000 -
Here is a second version that highlights the data range only:
Sub akrosarita()
Set rng = ActiveSheet.UsedRange.Columns("B").Cells
For Each itm In rng
With ActiveSheet.UsedRange.Rows(itm.Row - ActiveSheet.UsedRange.Row + 1)
.Interior.ColorIndex = itm.Value
End With
Next 'itm
End Sub
If you prefer Bob's code, it works fine aside from a minor typo. The term
Cells(i, "A").Value should be Cells(i, "B").Value.
--
Jay
" wrote:
Can someone please help me with VB code for the following process:
I have a list of items in column A (a database query linked to Access
table). The items are highlighted in different colors by the end-user.
When I refresh the database query the next day, the colors move around
or dissapear because new items get added to the list.
I added a vb function and call it in a hidden column B to display the
color index of cell A.
If OfText = True Then
CellColorIndex = InRange(1, 1).Font.ColorIndex
Else
CellColorIndex = InRange(1, 1).Interior.ColorIndex
End If
So, for example, cell A2 is highlighted in yellow, thus cell B2
displays number "6".
How can I create a vb code with a loop to go through the rows and
highlight the rows based on the value in column B?
Hopefully this makes sense.
Thank you in advance!