Coloring cells

P

Patrick Simonds

This is the code I use to color a cell based on text in the cell:

If Not Intersect(Target, Range("A5:G56")) Is Nothing Then

Select Case Left(Target.Text, 4)
Case Is = "Sick"
icolor = 38

End Select

How can I also get it to color the 2 cells immediately above it?
 
J

JE McGimpsey

Your code doesn't color anything...


However, you can try:

Dim iColor As Long
If Not Intersect(Target, Range("A5:G56")) Is Nothing Then
Select Case Left(Target.Text, 4)
Case Is = "Sick"
iColor = 38
Case Else
iColor = xlColorIndexNone
End Select
Target.Offset(-2, 0).Resize(3, 1).Interior.ColorIndex = iColor
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top