+ Reply to Thread
Results 1 to 6 of 6

Highlighting entire row

  1. #1
    Registered User
    Join Date
    10-10-2005
    Location
    Finland
    Posts
    10

    Highlighting entire row

    Hello everyone,

    I know how to change color for the active cell (ActiveCell.Interior.Colorindex=15) in Worksheet_SelectionChange Sub, but how can I change the color for the entire row where active cell is located? And to be more challenging, I want to change default color back when active cell is out of highlighted row.

  2. #2
    Norman Jones
    Guest

    Re: Highlighting entire row

    Hi Escelinen,

    See Chip Pearson's highlighting page at:

    http://www.cpearson.com/excel/excelM...ightActiveCell

    ---
    Regards,
    Norman



    "escelinen" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Hello everyone,
    >
    > I know how to change color for the active cell
    > (ActiveCell.Interior.Colorindex=15) in Worksheet_SelectionChange Sub,
    > but how can I change the color for the entire row where active cell is
    > located? And to be more challenging, I want to change default color
    > back when active cell is out of highlighted row.
    >
    >
    > --
    > escelinen
    > ------------------------------------------------------------------------
    > escelinen's Profile:
    > http://www.excelforum.com/member.php...o&userid=27966
    > View this thread: http://www.excelforum.com/showthread...hreadid=475704
    >




  3. #3
    Gary Keramidas
    Guest

    Re: Highlighting entire row

    this will highlight the entire row yellow

    ActiveCell.EntireRow.Interior.ColorIndex = 27

    --


    Gary


    "escelinen" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Hello everyone,
    >
    > I know how to change color for the active cell
    > (ActiveCell.Interior.Colorindex=15) in Worksheet_SelectionChange Sub,
    > but how can I change the color for the entire row where active cell is
    > located? And to be more challenging, I want to change default color
    > back when active cell is out of highlighted row.
    >
    >
    > --
    > escelinen
    > ------------------------------------------------------------------------
    > escelinen's Profile:
    > http://www.excelforum.com/member.php...o&userid=27966
    > View this thread: http://www.excelforum.com/showthread...hreadid=475704
    >




  4. #4
    Gary Keramidas
    Guest

    Re: Highlighting entire row

    that did help, norman, thanks. i almost had it but wasn't quite sure how to
    sotre the last range

    i adapted chip's code to highlight the entire row in case the op wanted it
    that way

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Static OldRange As Range
    On Error Resume Next
    Target.EntireRow.Interior.ColorIndex = 6 ' yellow - change as needed
    OldRange.EntireRow.Interior.ColorIndex = xlColorIndexNone
    Set OldRange = Target

    End Sub

    --


    Gary


    "Norman Jones" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Escelinen,
    >
    > See Chip Pearson's highlighting page at:
    >
    > http://www.cpearson.com/excel/excelM...ightActiveCell
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "escelinen" <[email protected]> wrote
    > in message news:[email protected]...
    >>
    >> Hello everyone,
    >>
    >> I know how to change color for the active cell
    >> (ActiveCell.Interior.Colorindex=15) in Worksheet_SelectionChange Sub,
    >> but how can I change the color for the entire row where active cell is
    >> located? And to be more challenging, I want to change default color
    >> back when active cell is out of highlighted row.
    >>
    >>
    >> --
    >> escelinen
    >> ------------------------------------------------------------------------
    >> escelinen's Profile:
    >> http://www.excelforum.com/member.php...o&userid=27966
    >> View this thread:
    >> http://www.excelforum.com/showthread...hreadid=475704
    >>

    >
    >




  5. #5
    Registered User
    Join Date
    10-10-2005
    Location
    Finland
    Posts
    10

    Thank You !

    That really solved the problem! Thank's a lot

  6. #6
    Jzz
    Guest

    Re: Highlighting entire row

    Hi all
    I've tried the code and it works more beautifull when you write it like
    this:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Static OldRange As Range
    On Error Resume Next
    OldRange.EntireRow.Interior.ColorIndex = xlColorIndexNone
    Target.EntireRow.Interior.ColorIndex = 6 ' yellow - change as needed
    Set OldRange = Target

    End Sub

    First change the oldrange to None and than change the newrange to
    yellow.
    Otherwise there is a problem when the new range contains the old range
    (for example old range = B4 and new range = B2:B6). Then the old range
    is set to blank after the new range is yellow.

    Grtz,

    Jzz


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1