Private Sub Worksheet_Change(ByVal Target As Range)
Dim plage As Range, trim%, txt$, W#, n%
' si AlternativeText est égal à "1", on continue l'exécution de cette macro sinon on quitte cette macro
If Me.Shapes("OKmacro").AlternativeText <> "1" Then Exit Sub
Set plage = Range("D18,D37,D56,D75")
Application.ScreenUpdating = False
Application.EnableEvents = False
For trim = 1 To 4
txt = "Montant Fonds Travaux " & trim & IIf(trim = 1, "er", "ème") & " Trimestre "
Set Target = plage.Areas(trim)
W = Target.ColumnWidth
n = 0
Do
n = n + 1
Target = txt & String(n, "-") & ">"
Target.Columns.AutoFit
Loop While Target.ColumnWidth < W + 1
Target.ColumnWidth = W
Target.Characters(Len(txt) - 14, 14).Font.Color = vbRed
Next trim
Application.EnableEvents = True
End Sub
Sub OKmacro()
Dim shp As Shape
' la forme s'appelle "OKmacro". AlternativeText de cette forme vaut "1" si la macro Worksheet_Change
' doit être exxécutée
Set shp = Me.Shapes("OKmacro") ' shp est la forme nommée "OKmacro" sur la feuille
' si AlternativeText de cette forme vaut "1" alors AlternativeText est mis à "0" sinon à "1"
shp.AlternativeText = IIf(shp.AlternativeText = "1", "0", "1")
' On adapte le texte de la forme en fonction de AlternativeText
shp.TextFrame2.TextRange.Characters.Text = IIf(shp.AlternativeText = 1, "Inhiber Worksheet_Change", "Activer Worksheet_Change")
End Sub