View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Berend Botje[_13_] Berend Botje[_13_] is offline
external usenet poster
 
Posts: 1
Default Highlighting a row in grey

Try the following:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
With Sh
With Target
If .Cells.Text = "Robert" Then
Rows(Target.Row).Interior.ColorIndex = 15
elseif .cells.text = "Jenny" Then
Rows(Target.Row).Interior.ColorIndex = (Enter number for color here)
Else: Rows(Target.Row).Interior.ColorIndex = xlNone
End If
End With
End With
End Sub


Ian M wrote:
*On 30 April, Nigel kindly gave me the following code to highlight a
row in Excel which contains the text "Robert". (NIGEL, forgive m
for
not replying to you personally; I have tried but my web browse
tells
me I cannot support the correct "cookies" when I click on the REPLY
button).

The code is as follows and works perfectly:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
With Sh
With Target
If .Cells.Text = "Robert" Then
Rows(Target.Row).Interior.ColorIndex = 15
Else
Rows(Target.Row).Interior.ColorIndex = xlNone
End If
End With
End With
End Sub

However I now need the statement to be amended so that it not only
highlights rows containing "Robert" in grey, but those containing
"Jenny" in a lighter shade of grey, thus visually differentiating
"Jenny" rows from the "Robert" rows.

I tried adding another "IF" statement underneath but it doesn'
work.

Also, can the code be amended further so that it only searches for
"Robert" or "Jenny" in Row "E".

Thanks again.

Kind regards

paddymichelle


--
Message posted from http://www.ExcelForum.com