Macro pour bouton

voila j'ai fait ce code mais en plus je voudrais qu"il execute une macro que j'ai creer

comment rajouter ma macro a ce code

Private Sub CommandButton1_Click()

If CommandButton1.BackColor = &HFF00& Then

CommandButton1.BackColor = &HC0C0C0

Else

CommandButton1.BackColor = &HFF00&

End If

End Sub

merci par avance

Bonjour,

Il suffit juste de mettre le nom de la macro à l'endroit où elle doit s’exécuter

par ex:

sub macro1

la macro.....

end sub

mettre macro1

Bonsoir mimi, M12

Private Sub CommandButton1_Click()
If CommandButton1.BackColor = &HFF00& Then
CommandButton1.BackColor = &HC0C0C0
Else
CommandButton1.BackColor = &HFF00&
End If
End Sub
mamacro

à la place de mamacro tu mets le nom de ta macro

Bye

Bonjour Patty

Non, le nom de la macro doit être entre le sub et le end sub

Private Sub CommandButton1_Click()
If CommandButton1.BackColor = &HFF00& Then
CommandButton1.BackColor = &HC0C0C0
macro1 ' soit là
Else
CommandButton1.BackColor = &HFF00&
macro1  'ou là
End If
macro1  'ou encore là tout dépend ce que doit faire la macro
End Sub

Pas compris ton explication

je rajoute dans :

Private Sub CommandButton1_Click()

If CommandButton1.BackColor = &HFF00& Then

CommandButton1.BackColor = &HC0C0C0

Else

CommandButton1.BackColor = &HFF00&

End If

macro 1

End Sub

ca marche merci

RE

Désolée M12 et mimi

C'est ce que je voulais faire bien sûr...

Je n'ai pas placé mon curseur correctement

mille pardons

Bonne soirée

Re,

De rien,

Il faut dire que l'explication de mon 1er post n'était pas très clair non plus

Rechercher des sujets similaires à "macro bouton"