Automatically highlighting rows which contains certain data

  • Thread starter Thread starter Ian M
  • Start date Start date
I

Ian M

In my Excel Workbook, I want the macro to find every row which
contains a cell containing the text "Robert" and then highlight this
row my shading it light grey.

The number of rows containing "Robert" changes all the time.

I know I need a Do ... Until statement, however I can't seem to come
to grips with the syntax and how to fit it into the macro.

Thanks.

Ian M
 
The following code behind the workbook will detect the entry as it is made
and set the row to grey if the cell contains Robert and reset it to no fill
if the word is removed

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
 
Nigel

This works perfectly.

Thank you for your help.

Kind regards

Ian M
 

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

Back
Top