Public Const NomComboBox = "MaComboBox"
Sub CréationComboBox()
Dim Top As Double, Left As Double, Width As Double, Height As Double
Dim CbB As Object
On Error Resume Next
'ActiveSheet.Shapes(NomComboBox).Delete
ActiveSheet.DropDowns(NomComboBox).Delete
On Error GoTo 0
'Cadre la ComboBox sur la cellule active
With ActiveCell
Top = .Top
Left = .Left
Width = .Width + 16
Height = .Height * 1.1
End With
'Création de la ComboBox Active X
Set CbB = ActiveSheet.DropDowns.Add(Left, Top, Width, Height)
CbB.Name = NomComboBox
CbB.AddItem "Item 1"
CbB.AddItem "Item 2"
CbB.AddItem "Item 3"
CbB.OnAction = "ActionComboBox"
End Sub
Sub ActionComboBox()
Dim CbB As Object
Set CbB = ActiveSheet.DropDowns(NomComboBox)
MsgBox CbB.Value
End Sub