MrCameronExcel
New Member
- Joined
- Apr 21, 2017
- Messages
- 43
- Office Version
- 365
- Platform
- Windows
Hi,
I am using the below code to produce a cross hair highlight (row and column) of selected cell. When I locked some cells, it no longer works and says to debug the code - shown in yellow below.
Anyone know any additional code to resolve this so I can maintain the VBA formatting below even when I lock cells?
Thank you
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
'Clear the color of all cells
Cells.Interior.ColorIndex = 0
With Target
'Highlight row and column of the selected cell
.EntireRow.Interior.ColorIndex = 38
.EntireColumn.Interior.ColorIndex = 24
End With
Application.ScreenUpdating = True
End Sub
I am using the below code to produce a cross hair highlight (row and column) of selected cell. When I locked some cells, it no longer works and says to debug the code - shown in yellow below.
Anyone know any additional code to resolve this so I can maintain the VBA formatting below even when I lock cells?
Thank you
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
'Clear the color of all cells
Cells.Interior.ColorIndex = 0
With Target
'Highlight row and column of the selected cell
.EntireRow.Interior.ColorIndex = 38
.EntireColumn.Interior.ColorIndex = 24
End With
Application.ScreenUpdating = True
End Sub