View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
SludgeQuake
 
Posts: n/a
Default How can i change cell colour depending on month of date in cell?

Here's a bit of code that might work (here, I have all dates in column A):

Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next

Dim i As Integer
Dim iColor As Integer

i = 0
iColor = 0

i = Month(Target.Value)

If Not Intersect(Target, Range("a:a")) Is Nothing Then
Select Case i
Case 1 To 3
iColor = 3
Case 4 To 6
iColor = 10
Case 7 To 9
iColor = 11
Case 10 To 12
iColor = 6
Case Else
End Select

Target.Font.ColorIndex = iColor

End If
End Sub

"andy75" wrote:


I have a column with a range of dates corresponding to when an item was
tested and would like to automatically change the colour depending on
which month it was tested. Jan-Mar = red, Apr-Jun= green, Jul-Sep=
blue and Oct-Dec= yellow. No date = no colour. Anyone have any
suggestions? Do I need to run a macro or is there a simpler way?

Thanks

Andy


--
andy75
------------------------------------------------------------------------
andy75's Profile: http://www.excelforum.com/member.php...o&userid=30177
View this thread: http://www.excelforum.com/showthread...hreadid=498604