1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Count > 1 Then GoTo fin
'*** Définition des variables ***
H = ActiveCell.Height
w2 = ActiveCell.Width
T = ActiveCell.Top
W = ActiveCell.Left
'Supprime les rectangles si existent déjà.
On Error Resume Next
ActiveSheet.Shapes("RectangleV").Delete
On Error Resume Next
ActiveSheet.Shapes("RectangleH").Delete
'Ajoute les rectangles
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 0, T, W, H).Name = "RectangleV"
With ActiveSheet.Shapes("RectangleV")
.Fill.Visible = msoFalse
.Fill.Transparency = 0#
.Line.Weight = 3#
.Line.ForeColor.SchemeColor = 10
.PrintObject = False
End With
ActiveSheet.Shapes.AddShape(msoShapeRectangle, W, 0, w2, T).Name = "RectangleH"
With ActiveSheet.Shapes("RectangleH")
.Fill.Visible = msoFalse
.Fill.Transparency = 0#
.Line.Weight = 3#
.Line.ForeColor.SchemeColor = 10
.PrintObject = False
End With
fin:
End Sub |