View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Brotha Lee Brotha Lee is offline
external usenet poster
 
Posts: 43
Default Change background based on value in another column

MM,

You could use regular Excel functionality like conditional formatting (under
format menu), however if you desire a code use the following. You should
paste it somewhere in the appropriate sheet object
Private Sub Worksheet_Change(ByVal Target As Range)
'Use Lcase(Target) if it should not be case sensitive
Select Case Target
Case Is = "a"
Cells(Target.Row, 2).Interior.Color = vbRed
Cells(Target.Row, 3).Interior.Color = vbRed
Case Is = "b"
Cells(Target.Row, 2).Interior.Color = vbGreen
Cells(Target.Row, 3).Interior.Color = vbGreen
Case Else
'No appropriate entry, clear color
Cells(Target.Row, 2).Interior.ColorIndex = xlNone
Cells(Target.Row, 3).Interior.ColorIndex = xlNone
End Select

End Sub

HTH
Brotha lee

"MM User" wrote:

Hi,

I have in column A options: a,b,c or d

depending on what is chosen is it possible change the background color of
the relevant row in B and C?

i.e. if a3 = a then b3 & d3 background is red or
if a3 = b then b3 & d3 background is green etc

If possible is it possible to do this automatically i.e. not run a macro
just on a cell change in A?

Thanks!