Recalculer après un changement de format
Application.volatile permet de recalculer lorsqu'une cellule a été modifiée dans sa valeur mais pas dans son format. Tu peux cependant intercepter l'action du bouton qui met en gras. La macro intercept_gras" détecte l'action et lance la macro "trouvé" qui elle, met du gras ou l'enlève et recalcule. Lla 3ème macro sert à réinitialiser l'action normale de la mise en gras.
sub intercept_gras()
Dim Ctl As CommandBarControl
For Each Ctl In Application.CommandBars("Formatting").Controls
If Ctl.Caption = "&Gras" Then
Ctl.OnAction = "trouvé"
End If
Next Ctl
end subsub trouvé()
If Selection.Font.Bold = True Then
Selection.Font.Bold = False
Else
Selection.Font.Bold = True
End If
Calculate
end subsub reinit_Gras()
Dim Ctl As CommandBarControl
For Each Ctl In Application.CommandBars("Formatting").Controls
If Ctl.Caption = "&Gras" Then
Ctl.OnAction = ""
End If
Next Ctl
end subAuteur : popi
Mots clefs associés à cette page : format, volatile, recalculer
- Vous devez vous identifier ou créer un compte pour écrire des commentaires
