A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
You don't need Dim LastRow as Long
You can define your range with a few less references also.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "C7:G11"
If Not Intersect(Target, Range(WS_RANGE)) Is Nothing Then
On Error GoTo endit 'trap for error so's events get re-enabled
Application.EnableEvents = False
With Selection.Borders(xlDiagonalDown)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlDiagonalUp)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.249977111117893
End With
End If
endit:
Application.EnableEvents = True
End Sub