Results 1 to 3 of 3

Thread: Highlighting part row when cell clicked on

  1. #1
    Neophyte willmac's Avatar
    Join Date
    May 2019
    Posts
    3
    Articles
    0
    Excel Version
    2007 .xlsm

    Highlighting part row when cell clicked on



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi, I have found plenty of info on highlighting a row when a cell is clicked on but what I really wanted was that if a cell was clicked on in a row I only want to highlight the part of that row from column A to column G. If that's possible I only want to start from row 7 downwards as I have headers above this.

  2. #2
    Administrator AliGW's Avatar
    Join Date
    Nov 2015
    Location
    Ipswich, Suffolk, England
    Posts
    1,282
    Articles
    0
    Excel Version
    Office 365 Subscription
    I've moved your thread to the VBA section, as this is a VBA question.
    Ali
    Enthusiastic self-taught user of MS Excel!

  3. #3
    Neophyte Knoet's Avatar
    Join Date
    May 2019
    Posts
    4
    Articles
    0
    Excel Version
    2016
    Like this?
    Code goes in the sheet module.
    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Range("A7:G200"), Target) Is Nothing Then 'modify range according to your needs
    Dim cl As Range, y As Integer, tr As Integer, mycolor As Integer
    tr = Target.Row: mycolor = 8
    For Each cl In Range("A7:G200") 'modify range according to your needs
    If cl.Interior.ColorIndex = mycolor Then
    cl.Interior.ColorIndex = -4142
    End If
    Next cl
    For y = 1 To 7
    If Cells(tr, y).Interior.ColorIndex = -4142 Then
    Cells(tr, y).Interior.ColorIndex = mycolor
    End If
    Next y
    End If
    End Sub

Posting Permissions

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