1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Private Sub Worksheet_Activate()
With Application.CommandBars("cell").Controls.Add(msoControlButton)
.Caption = "Premiere prestation"
End With
For Each cmddroit In Application.CommandBars("cell").Controls
If cmddroit.Type = msoControlComboBox Then cmddroit.Delete
Next cmddroit
Set myControl = CommandBars("cell").Controls.Add(Type:=msoControlComboBox, Before:=19)
With myControl
For x = 1 To 12
.AddItem Text:=Cells(x, 1), Index:=x
Next
.ListIndex = 1
.DropDownLines = 6
.DropDownWidth = 70
.ListHeaderCount = 1
.Tag = "menuquatre"
.OnAction = "premjour"
End With
End Sub
et sa macro
Sub premjour()
Dim quatrebtn As CommandBarComboBox, strTxt As String
Set quatrebtn = CommandBars("cell").FindControl(, , "menuquatre")
strTxt = quatrebtn.Text
ActiveCell = strTxt
End Sub |
Partager