SOLVED

Highlight the column header of the selected cell | Solved

Brass Contributor

Hello everyone I hope you are well.
Just a small request, I have the file shown above and I would like to highlight the column header of the selected cell

Before.png

 

 

 

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

ActiveSheet.Protect DrawingObjects:=False, Contents:=False, Scenarios:=False
    ActiveSheet.EnableSelection = xlNoRestrictions
    
If Sh.Name = "6" Then Exit Sub

If Not Application.Intersect(Target, Range("C3:AM45")) Is Nothing Then

Range("C3:AM45").Interior.ColorIndex = xlColorIndexNone

Columns("C:AM").Interior.ColorIndex = 2

Columns("C:AM").Interior.Color = RGB(255, 255, 255)

Target.EntireRow.Range("C1:AM1").Interior.Color = RGB(255, 228, 181)

Target.Range("C1:AM1").Cells(0, -1).Interior.Color = RGB(255, 255, 0)

Target.Interior.Color = RGB(255, 255, 0)

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    ActiveSheet.EnableSelection = xlNoRestrictions

End If

End Sub

 

 

 

Expect

 

After.png

 

2 Replies
best response confirmed by X_23 (Brass Contributor)
Solution

@X_23 

I don't really understand your code, but perhaps add the following line above the line that protects the sheet just before the end of the code:

Sh.Cells(2, Target.Column).Interior.Color = RGB(255, 255, 0)
Thank you so much works perfectly
1 best response

Accepted Solutions
best response confirmed by X_23 (Brass Contributor)
Solution

@X_23 

I don't really understand your code, but perhaps add the following line above the line that protects the sheet just before the end of the code:

Sh.Cells(2, Target.Column).Interior.Color = RGB(255, 255, 0)

View solution in original post