View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Simon Lloyd[_768_] Simon Lloyd[_768_] is offline
external usenet poster
 
Posts: 1
Default Changing cell colour depending on content??


Hi all, I am trying to get cells in a certain range to change colou
depending on their content, i need to check for a name and any othe
word in the cell i.e Cheryl Home where home could be a variable (als
it shouldnt matter what case it is in) then when it finds the name an
variable change the cells colour and leave only the variable visible i
the cell!

Here's what i have so far it doesn't quite work!
Dim mycell
Dim rng As Range
Set rng = Range("B4:M46")
For Each mycell In rng
If mycell = "" Then
Exit Sub
ElseIf mycell.Value = "Cheryl" & "*" Then
mycell.Select
End If
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
If mycell.Value = "Emma" & "*" Then
mycell.Select
End If
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
If mycell.Value = "Lauren" & "*" Then
mycell.Select
End If
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Next

Hope you can help!

Reagrds
Simo

--
Simon Lloy
-----------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670
View this thread: http://www.excelforum.com/showthread.php?threadid=55206