View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default VB Code Highlight Rows Based on Color Index


For i = 1 To cells(Rows.Count,"B").End(xlUp).Row
rows(i).Interior.Colorindex = Cells(i,"A").Value
Next i

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



wrote in message
ups.com...
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!