View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
david mcritchie david mcritchie is offline
external usenet poster
 
Posts: 691
Default Conditional Formatting adjacent cells

Hi Rachel,
See my previous response in this thread, but it sounds like you
are still looking for an answer; otherwise you would have said you
had your answer.

This example will change the color of the entire row based on
the value manually entered into Column F (column 6) having
"Yes" or "No" with an Event Macro instead of using Conditional Formatting. .

VBA is case sensitive whereas the worksheet formulas used in
Conditional Formatting were not, so the testing will be of the
value as converted to lowercase.

Read again about Event Macros in
http://www.mvps.org/dmcritchie/excel/event.htm#case

To install right click on the sheet tab then View code, insert code

Private Sub Worksheet_Change(ByVal Target As Range)
'David McRitchie, 2004-09-26, programming, Case -- Entire Row
' http://www.mvps.org/dmcritchie/excel/event.htm#case_row
If Target.Column < 6 Then Exit Sub 'Column F is column 6
If Target.Row = 1 Then Exit Sub
Application.EnableEvents = False 'should be part of Change macro
Select Case LCase(Target.Value)
Case "yes"
Target.EntireRow.Interior.ColorIndex = 34
Case "no"
Target.EntireRow.Interior.ColorIndex = 36
Case Else
Target.EntireRow.Interior.ColorIndex = xlColorIndexAutomatic
End Select
Application.EnableEvents = True 'should be part of Change macro
End Sub
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Rachel Curran" wrote in message
Yes, I need this to be in code please