Sub MsgBoxListeDeChoix2()
Dim WS As Worksheet
Set WS = ActiveSheet
Dim tbl() As Variant
'tbl = Array(0, 2, 5, 10, 15, 20, 30, 0)
tbl = Array(0, 2, 5, 10, 15, 20, 30)
' Msgbox
'tbl(UBound(tbl)) = MsgBox("Liste de choix", tbl(UBound(tbl)), "CLIC SUR LA BONNE REPONSE")
' Les valeurs
'ReDim Preserve tbl(UBound(tbl) - 1)
' La Liste Box
Dim oCombo As OLEObject
Dim L As Single, T As Single, W As Single, H As Single
L = ActiveCell.Left ' L = 180 '<-- position horizontale
T = ActiveCell.Top ' T = 80 '<-- position verticale
W = ActiveCell.Width ' W = 130 '<-- largeur
H = ActiveCell.Height ' H = 22 '<-- hauteur
' Si la liste existe
For Each oCombo In WS.OLEObjects
If oCombo.progID = "Forms.ComboBox.1" Then
If oCombo.Name = "Combo1" Then
oCombo.Delete
End If
End If
Next
' Creation de la liste de choix
Set oCombo = WS.OLEObjects.Add(ClassType:="Forms.ComboBox.1", Left:=L, Top:=T, Width:=W, Height:=H)
With oCombo
.Name = "Combo1" '<-- nom du Combobox
.Object.List() = tbl '<-- exemple de chargement des données
.Object.TextAlign = 3 ' Aligne le texte a droite
.Object.DropDown ' Déroule le menu
End With
Set oCombo = Nothing: Set WS = Nothing: Erase tbl
L = Empty: T = Empty: W = Empty: H = Empty
End Sub