Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney, New South Wales, Australia
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I want to highlight the cell in Column B that is in the same row as the active cell.
    So if the active cell is K17 then I'd like B17 is highlighted

    Thank you PaulGD

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Hi Paul,

    Try:
    Code:
    Sub Demo()
    Range(Cells(ActiveCell.Row, 2).Address).Interior.ColorIndex = 6
    End Sub
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    You have overcomplicated it a little. This will do the same thing more directly:

    Cells(ActiveCell.Row, 2).Interior.ColorIndex = 6

    Steve

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Hi Steve,

    All I can say is it's been a long day ...
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney, New South Wales, Australia
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much

    Now to get the cell to revert to not-highlighted when I select the next cell,
    I created a named range called RevertRow so the code knows which row was the previous ActiveCell.Row
    and then reverted the old highlighted cell to unfilled.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Cells(Range("RevertRow"), 2).Interior.ColorIndex = 0
    Cells(ActiveCell.Row, 2).Interior.ColorIndex = 6
    Range("RevertRow") = ActiveCell.Row
    End Sub

    But is there a way that doesn't rely on a value being stored on the worksheet.
    Can I declare a variable (Dim RevertRow as String) that stays valid & holds it's value for next time the sub is run

  6. #6
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    If you want to do this live, I suggest you look at Chip Pearson's RowLiner addin
    http://www.cpearson....el/RowLiner.htm

    This seems to be similar to what you are after...

    Steve

  7. #7
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney, New South Wales, Australia
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the RowLiner addin link

Posting Permissions

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