ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can you use formulas to manipulate the fill color of a cell? (https://www.excelbanter.com/excel-programming/395829-re-can-you-use-formulas-manipulate-fill-color-cell.html)

JLGWhiz

Can you use formulas to manipulate the fill color of a cell?
 
Assume your goal is 80 and the cell is A1.

Private Sub Worksheet_Change(By Val Target As Range)
If Cells(1, 1) <= 79 And Cells(1, 1) < "" Then
Cells(1, 1).Interior.ColorIndex = 3
Cells(1, 1).Font.ColorIndex = 2
ElseIf Cells(1, 1) = 80 And Cells(1, 1) < "" Then
Cells(1, 1).Interior.ColorIndex = 10
Cells(1, 1).Font.ColorIndex = 1
End If
End Sub

This would go in your Worksheet code module. Right click the sheet tab,
click view code, copy above code and paste into module.

"kAustin79" wrote:

I have Excel 2003. I want to change the fill color of a cell in relation to
it's own contents (ex. I will set a number as a goal for myself. There will
be a cell that will calculate my progress. While I am still under my goal
number, the fill color of the cell will be red and the text white - Once I
exceed my goal, the fill color will turn green and the text will be black).



All times are GMT +1. The time now is 07:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com