Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default change colour on value, 4+ colors


Thanks Bob,

That works pefectly!

Nejl


Bob Phillips Wrote:
Try this variation, it should cater for formulae and direct entry

Private Sub Worksheet_Calculate()
Dim cell As Range
For Each cell In Range("S:S")
If Not IsEmpty(cell.Value) Then
UpdateColour cell
End If
Next cell

End Sub

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("S:S")) Is Nothing Then Exit Sub
UpdateColour Target

End Sub

Private Sub UpdateColour(ByVal Target As Range)

Select Case LCase(Target.Value)
Case Is = "1": Cells(Target.Row, "B").Interior.ColorIndex = 3
Case Is = "2": Cells(Target.Row, "B").Interior.ColorIndex = 46
Case Is = "3": Cells(Target.Row, "B").Interior.ColorIndex = 6
Case Is = "4": Cells(Target.Row, "B").Interior.ColorIndex = 4
Case Is = "5": Cells(Target.Row, "B").Interior.ColorIndex = 34
Case Else:
Cells(Target.Row, "B").Interior.ColorIndex = xlColorIndexNone
End Select

End Sub





--
nejlangto
-----------------------------------------------------------------------
nejlangton's Profile: http://www.excelforum.com/member.php...fo&userid=1397
View this thread: http://www.excelforum.com/showthread.php?threadid=26428

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Colour One cell with two colors Muffi Zainu[_2_] Excel Discussion (Misc queries) 5 January 8th 10 02:01 PM
Colour One cell with two colors Muffi Zainu Excel Discussion (Misc queries) 2 December 8th 09 02:18 PM
change a cell background colour to my own RGB colour requirements Stephen Doughty Excel Discussion (Misc queries) 4 June 16th 06 01:08 PM
change colour on value, 4+ colors nejlangton[_5_] Excel Programming 1 September 29th 04 11:12 AM
change colour on value, 4+ colors nejlangton[_4_] Excel Programming 1 September 28th 04 05:32 PM


All times are GMT +1. The time now is 01:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"