Private Sub ActiveX_Click()
MsgBox "Bonjour Chantal, le forum !"
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
Set c = [D4] 'à adapter
If Intersect(Target, c) Is Nothing Then Exit Sub
On Error Resume Next
'---suppression du bouton---
If c = "" Then OLEObjects("ActiveX").Delete: Exit Sub
'---création du bouton---
If IsError(OLEObjects("ActiveX")) Then
With OLEObjects.Add("Forms.CommandButton.1", Width:=0)
.Name = "ActiveX"
.Object.Caption = "Message" 'à adapter
.Object.Font.Bold = True 'gras
.Object.TakeFocusOnClick = False
.Top = c(3).Top
.Left = c.Left + c.Width / 2 - 50
.Height = 31
.Width = 100
End With
End If
'---coloration du bouton---
OLEObjects("ActiveX").Object.BackColor = Application.VLookup(c, [{"Orange",49407;"Jaune",65535;"Vert",10092441;"Gris",14277081}], 2, 0)
End Sub