Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Set champ = [A1:f20]' ADAPTE LA PLAGE QUE TU VEUX
Dim shp1 As Boolean, shp2 As Boolean, shap1 As Shape, shap2 As Shape
For Each shap In ActiveSheet.Shapes
If shap.Name = "curseurV" Then shp1 = True
If shap.Name = "curseurH" Then shp2 = True
Next
If Not shp1 Then
Set shap1 = ActiveSheet.Shapes.AddShape(1, 1, 1, 2000, 1): shap1.Name = "curseurH"
shap1.Line.ForeColor.RGB = RGB(255, 0, 0)
End If
If Not shp2 Then
Set shap2 = ActiveSheet.Shapes.AddShape(1, 1, 1, 1, 2000): shap2.Name = "curseurV"
shap2.Line.ForeColor.RGB = RGB(255, 0, 0)
End If
If Not Intersect(champ, Target) Is Nothing Then
With ActiveSheet.Shapes("curseurV"): .Top = 0: .Left = Target.Left: .Visible = True: End With
With ActiveSheet.Shapes("curseurH"): .Top = Target.Top + Target.Height: .Left = 0: .Visible = True: End With
Else
ActiveSheet.Shapes("curseurH").Visible = False
ActiveSheet.Shapes("curseurV").Visible = False
End If
End Sub