Results 1 to 3 of 3

Thread: Highlight Row VBA Toggle command
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Aug 2018
    Posts
    109
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Highlight Row VBA Toggle command

    Hi,

    Is it possible to create code to highlight the row of the selected cell?



    I use two screens so even if I select the whole row when I go to my second display excel doesnt show the highlighted row when I select a different window.



    I was hoping it was also possible to have a macro that toggles this so I could set a shortcut key which will swicth this on and off as I select different rows.


    Thanks in advance.

  2. #2
    Board Regular
    Join Date
    Aug 2003
    Location
    England
    Posts
    5,615
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    2 Thread(s)

    Default Re: Highlight Row VBA Toggle command

    Hello,

    This code will highlight the active row, from cols A - L.


    Code:
    Sub COLOUR_ROW()
        If Selection.Cells.Count > 1 Then End
            With ActiveSheet
                .Rows("1:65536").Interior.ColorIndex = xlNone
                .Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, 12)).Cells.Interior.ColorIndex = 36
            End With
    End Sub
    and this code will unhighlight all rows.

    Code:
    Sub UNCOLOUR_ROW()
        With ActiveSheet
            .Rows("1:65536").Interior.ColorIndex = xlNone
        End With
    End Sub
    This will affect any background coloured cells already created.

    Change columns required as necessary, as well as colour. Not sure about the two screens, as I don't have this. But it may point you in the right direction.
    Last edited by onlyadrafter; Sep 18th, 2019 at 08:46 AM.
    -------------------------
    Hope this is helpful.
    -------------------------

    Have been away from the forum for quite a while, but am now back.

  3. #3
    Board Regular
    Join Date
    Aug 2018
    Posts
    109
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Highlight Row VBA Toggle command

    Quote Originally Posted by onlyadrafter View Post
    Hello,

    This code will highlight the active row, from cols A - L.


    Code:
    Sub COLOUR_ROW()
        If Selection.Cells.Count > 1 Then End
            With ActiveSheet
                .Rows("1:65536").Interior.ColorIndex = xlNone
                .Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, 12)).Cells.Interior.ColorIndex = 36
            End With
    End Sub
    and this code will unhighlight all rows.

    Code:
    Sub UNCOLOUR_ROW()
        With ActiveSheet
            .Rows("1:65536").Interior.ColorIndex = xlNone
        End With
    End Sub
    This will affect any background coloured cells already created.

    Change columns required as necessary, as well as colour. Not sure about the two screens, as I don't have this. But it may point you in the right direction.
    This is perfect. It did affect current colouring but I just changed it to start at row 3 so its fine now.



    It comes with the added bonus that when I select a new row it clears the previous row.



    Thanks very much for your help with this.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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