Option Explicit
Dim h, w2, t, w
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
' Code de Gaetan Mourmant : merci !
h = ActiveCell.Height
w2 = ActiveCell.Width
t = ActiveCell.Top
w = ActiveCell.Left
On Error Resume Next
ActiveSheet.Shapes("RectangleV").Delete
ActiveSheet.Shapes("RectangleH").Delete
On Error GoTo 0
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 0, t, w, h).Name = "RectangleV"
With ActiveSheet.Shapes("RectangleV")
.Fill.Visible = msoFalse
.Line.Weight = 3#
.Line.ForeColor.SchemeColor = 10
.ControlFormat.PrintObject = False
End With
ActiveSheet.Shapes.AddShape(msoShapeRectangle, w, 0, w2, t).Name = "RectangleH"
With ActiveSheet.Shapes("RectangleH")
.Fill.Visible = msoFalse
.Line.Weight = 3#
.Line.ForeColor.SchemeColor = 10
.ControlFormat.PrintObject = False
End With
Columns.AutoFit
End Sub