![]() |
changing the color of a cell acording to its value
Hi.. I wanna a macro that can change the color of a cell acording to its
value. I've tried conditional formating, but it doesnt work cause I have 5 ranges of values. from 0% to 79% = black with white font from 80% to 84% = red with white font from 85% to 87% = white with red font. from 88% to 92% = yellow with red font from 92% to 100% = green with white font Could you helpme?? |
changing the color of a cell acording to its value
This will apply formatting to every cell in your current selection (I.e., if
you select range A1:D4, formatting will be applied to those 16 cells) Sub CellColor() for each cell in selection If Cell.Value = 0 And Cell.Value <= 0.79 Then 'Black with white Selection.Font.ColorIndex = 2 Selection.Interior.ColorIndex = 1 End If If Cell.Value 0.79 And Cell.Value <= 0.84 Then 'Red with white Selection.Font.ColorIndex = 2 Selection.Interior.ColorIndex = 3 End If If Cell.Value 0.84 And Cell.Value <= 0.87 Then 'White with red Selection.Font.ColorIndex = 3 Selection.Interior.ColorIndex = 2 End If If Cell.Value 0.87 And Cell.Value <= 0.92 Then 'Yellow with red Selection.Font.ColorIndex = 3 Selection.Interior.ColorIndex = 6 End If If Cell.Value 0.92 And Cell.Value <= 1 Then 'Green with white Selection.Font.ColorIndex = 2 Selection.Interior.ColorIndex = 10 End If next cell End Sub -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "Dani Lima" wrote: Hi.. I wanna a macro that can change the color of a cell acording to its value. I've tried conditional formating, but it doesnt work cause I have 5 ranges of values. from 0% to 79% = black with white font from 80% to 84% = red with white font from 85% to 87% = white with red font. from 88% to 92% = yellow with red font from 92% to 100% = green with white font Could you helpme?? |
changing the color of a cell acording to its value
Conditional formatting works for me in 2007.
-- Roland "Dani Lima" wrote: Hi.. I wanna a macro that can change the color of a cell acording to its value. I've tried conditional formating, but it doesnt work cause I have 5 ranges of values. from 0% to 79% = black with white font from 80% to 84% = red with white font from 85% to 87% = white with red font. from 88% to 92% = yellow with red font from 92% to 100% = green with white font Could you helpme?? |
All times are GMT +1. The time now is 02:01 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com