Highlight ROW excel VBA

Posted on 2013-05-18
Medium Priority
Last Modified: 2013-05-18
can you please help,
I'm trying to highlight the Row based on if cell Contains specific text  "RETURN"  

Example , cell has this text

it is not Highlighting the Row.

Sub HighLight_Retrun_cells()
i = 2
For Each c In ActiveSheet.Range("E2:E" & Range("E" & Rows.Count).End(xlUp).Row)
    If Cells(i, 5) = "RETURN" Then
        Rng = "A" & i & ":" & "O" & i
        Range(Rng).Interior.ColorIndex = 6
    End If
    i = i + 1
    Next c
End Sub

Any help is appreciated.
Question by:W.E.B
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 34

Accepted Solution

Norie earned 1000 total points
ID: 39177766
Try this.
Sub HighLight_Retrun_cells()
Dim c As Range

    For Each c In Sheets("Detail").Range("E2:E" & Range("E" & Rows.Count).End(xlUp).Row)
        If c.Value Like "*RETURN*" Then
            c.Offset(, -4).Resize(, 15).Interior.ColorIndex = 6
        End If
    Next c

End Sub

Open in new window


Author Comment

ID: 39177771
This does it,
thank you.

Author Closing Comment

ID: 39177772

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question