ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   colouring a cell (https://www.excelbanter.com/excel-programming/350094-colouring-cell.html)

andy617

colouring a cell
 

I would like a cell from a range to change colour whenever some text is
entered into it.
For example, if I type in a date or text like 'yes or no' into a cell
ranging from F4:F44 then it will turn the cell colour yellow.

Could anyone offer any help on this.

Thanks


--
andy617
------------------------------------------------------------------------
andy617's Profile: http://www.excelforum.com/member.php...o&userid=21835
View this thread: http://www.excelforum.com/showthread...hreadid=500150


Steve Steiner

colouring a cell
 


"andy617" wrote:


I would like a cell from a range to change colour whenever some text is
entered into it.
For example, if I type in a date or text like 'yes or no' into a cell
ranging from F4:F44 then it will turn the cell colour yellow.

Could anyone offer any help on this.

Thanks


--
andy617
------------------------------------------------------------------------
andy617's Profile: http://www.excelforum.com/member.php...o&userid=21835
View this thread: http://www.excelforum.com/showthread...hreadid=500150



Steve Steiner

colouring a cell
 
Here is what I did for an application I wrote. Hope it helps and is useful:

Public pubColors(9) As Integer

Sub some_process1()
Dim idxColors As Integer

' load up the pubColors array
' 0 = Black
' 1 = Black
' 2 = White
' 3 = Red
' 4 = Bright Green
' 5 = Blue
' 6 = Yellow
' 7 = Magenta
' 8 = Cyan
' 9 = Brown
For idxColors = 0 To 9
pubColors(idxColors) = idxColors
Next idxColors

Call some_process2()
End Sub

Sub some_process2()
Dim MyColor As Integer

MyColor = 3
Call Color_It(MyColor)
End Sub

Sub some_process2()
If [Feb05_SOD_Closed] < [Jan05_SOD_Closed] Then
[Feb05_SOD_Closed].Font.ColorIndex = MyColor
End If
If [Mar05_SOD_Closed] < [Feb05_SOD_Closed] Then
[Mar05_SOD_Closed].Font.ColorIndex = MyColor
End If
If [Apr05_SOD_Closed] < [Mar05_SOD_Closed] Then
[Apr05_SOD_Closed].Font.ColorIndex = MyColor
End If
If [May05_SOD_Closed] < [Apr05_SOD_Closed] Then
[May05_SOD_Closed].Font.ColorIndex = MyColor
End If
If [Jun05_SOD_Closed] < [May05_SOD_Closed] Then
[Jun05_SOD_Closed].Font.ColorIndex = MyColor
End If
If [Jul05_SOD_Closed] < [Jun05_SOD_Closed] Then
[Jul05_SOD_Closed].Font.ColorIndex = MyColor
End If
If [Aug05_SOD_Closed] < [Jul05_SOD_Closed] Then
[Aug05_SOD_Closed].Font.ColorIndex = MyColor
End If
If [Sept05_SOD_Closed] < [Aug05_SOD_Closed] Then
[Sept05_SOD_Closed].Font.ColorIndex = MyColor
End If
If [Oct05_SOD_Closed] < [Sept05_SOD_Closed] Then
[Oct05_SOD_Closed].Font.ColorIndex = MyColor
End If
If [Nov05_SOD_Closed] < [Oct05_SOD_Closed] Then
[Nov05_SOD_Closed].Font.ColorIndex = MyColor
End If
If [Dec05_SOD_Closed] < [Nov05_SOD_Closed] Then
[Dec05_SOD_Closed].Font.ColorIndex = MyColor
End If
End Sub



"andy617" wrote:


I would like a cell from a range to change colour whenever some text is
entered into it.
For example, if I type in a date or text like 'yes or no' into a cell
ranging from F4:F44 then it will turn the cell colour yellow.

Could anyone offer any help on this.

Thanks


--
andy617
------------------------------------------------------------------------
andy617's Profile: http://www.excelforum.com/member.php...o&userid=21835
View this thread: http://www.excelforum.com/showthread...hreadid=500150




All times are GMT +1. The time now is 09:46 AM.

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