G
gerome1980
Guest
Bonjour,
voila j'essaie de créer une barre avec 8 boutons, chacun affecté de la même macro mais avec paramètre différent. Voilà le code:
Je ne comprends pas pourquoi ça ne marche pas au niveau du OnAction; Excel me dit qu'il ne trouve pas la macro formatage p.
Comment faire?
Merci,
Jerome
voila j'essaie de créer une barre avec 8 boutons, chacun affecté de la même macro mais avec paramètre différent. Voilà le code:
Code:
Sub creation_barre()
unité = Range('A3').Value
prefixe = Array('m', 'c', 'd', '', 'da', 'h', 'k', 'M')
Dim bouton(8)
Dim i As Integer
Set barre_formatage = CommandBars.Add(Name:='Conversion', _
Position:=msoBarFloating, MenuBar:=False, temporary:=True)
With barre_formatage
.Visible = True
For i = 0 To 7
Set bouton(i) = .Controls.Add(Type:=msoControlButton)
Next
End With
For p = 0 To 7
With bouton(p)
.Caption = prefixe(p) & unité
.OnAction = ''formatage p''
.Style = msoButtonCaption
End With
Next
End Sub
Sub formatage()
Selection.NumberFormat = '0.00'' ' & prefixe(p) & unité & ''''
End Sub
Je ne comprends pas pourquoi ça ne marche pas au niveau du OnAction; Excel me dit qu'il ne trouve pas la macro formatage p.
Comment faire?
Merci,
Jerome