Sabealgo
asked on
Excel - Color coding a row or rows based on the value of one cell.
How do I write a macro that looks at column D and highlights the entire row based on that value? The macro needs to look at the values of a certain cell and based on that value change the entire row to one color or another.
For example, I work on a list of quote requests. The list contains requests from four different vendors. Because the data on each row of the list is so similar, I would like to color code the row based on the vendor's name so that the line can be easily identified.
Specifically, Row D contains the vendors name. - The data on that row, extends from column A through BA. A sample spreadsheet is attached.
For example, I work on a list of quote requests. The list contains requests from four different vendors. Because the data on each row of the list is so similar, I would like to color code the row based on the vendor's name so that the line can be easily identified.
Specifically, Row D contains the vendors name. - The data on that row, extends from column A through BA. A sample spreadsheet is attached.
Sample file not found. Does this have to be a macro or can you also use conditional formatting?
ASKER
I would like it to be a macro so that I can color the entire row line - not just the cell with the matching name. I will try the first solution and see if that works.
ASKER
Hello Imnorie,
Can you provide me with the color for light blue, light yellow, light green and tan? As if I were to take a highlighter pen and highlight each line.
Thanks.
Can you provide me with the color for light blue, light yellow, light green and tan? As if I were to take a highlighter pen and highlight each line.
Thanks.
You can use rgbLightBlue, rgbLightYellow, rgbLightGreen and rgbTan.
With conditional formatting, you can color the entire row line based on a match in one cell
ASKER
Imnorie,
So then it would be ?
Select Case cl.Value
Case "VendorA"
idxcolor = rgbLightBlue
?
So then it would be ?
Select Case cl.Value
Case "VendorA"
idxcolor = rgbLightBlue
?
Yes, if you wanted VendorA rows to be coloured light blue.
ASKER
When I plug in the idxcolor - rgbLightBlue all of the lines associated with that vendor are coded black. Similarly, when I used the other rgb colors, they came up coded as black as well.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
How would you like to colour code each row?
This would colour the rows with VendorA in column D green, with VendorB red and VendorC yellow.
Open in new window