Highlight Row

  • I Would Like Some Help Writing A Macro That Will Highlight The Entire Row Where An Active Cell Is Selected. The Only Kicker Is That You Can Not Use Conditional Formating. I Have Many Cells That Use Conditional Formatting Where I Have Used All 3 Conditions. The Other Option Is That If Someone Knows A Way To Get A Cell To Change To A Different Color Based On Whats In The Cell That Would Work Great Too. I Need More Then Just 3 Conditional Formats. So I Guess This Is A Two Part Question.


    Thanks In Advance

  • Re: Highlight Row


    HI zotee98,


    One way is to use a Worksheet_Change procedure and a Select Case. In the following code any cell in the active spreadsheet will change color if a number 1 through 6 is entered into the cell. Any other number will change the color to “no fell”.



    Bill

    [FONT="Arial Black"][COLOR="blue"][SIZE="4"]Bill[/SIZE][/COLOR][/FONT]
    Tip: To avoid chasing code always use Option Explicit.

  • Re: Highlight Row


    To answer your first question of needing to highlight the entire row of the selected cell, try this below. There is one catch, the highlighting remains on whatever rows you previously selected as well. I'm not sure if you desire this or not


  • Re: Highlight Row


    An excellent solution posted by DROM under the Thread "Highlight a row when a cell in that row is clicked" started by ctg. This thread should appear under similar threads at the top of your screen.


    Code
    Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    'this highlights the selected cell's entire row
    Cells.Interior.ColorIndex = xlNone
    With ActiveCell
    .EntireRow.Interior.ColorIndex = 27
    End With
    End Sub


    He also posts a solution for having something happen on a particular row selected, like row#5, if desired.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!