Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

regrouper plusieurs macro en un seul bouton

tonychange

XLDnaute Occasionnel
Bonjour,
J'aimerais savoir si il est possible de regrouper plusieurs macro en un seul bouton sur excel??
Dans mon cas, j'ai 6 macros et j'aimerais regrouper ces 3 formules dans 1 bouton.

merci d"avance
 

Pierrot93

XLDnaute Barbatruc
Re : regrouper plusieurs macro en un seul bouton

Bonjour Tony

peut être comme ceci, si j'ai bien compris la question...

Code:
Private Sub CommandButton1_Click()
macro1
macro2
macro3
macro4
macro5
macro6
End Sub

bonne fin d'après midi
@+
 

tonychange

XLDnaute Occasionnel
Re : regrouper plusieurs macro en un seul bouton

voici mes macros

j'ai rajouté la focntion mais ca ne fonctionne pas

Sub Macro1()
'
' Macro1 Macro
' Macro enregistrée le 08/07/2009 par ritchy
'

'
Rows("1:2").Select
Selection.Delete Shift:=xlUp
ActiveSheet.Shapes("Picture 1").Select
Selection.Delete
Range("A1:M1").Select
Selection.Interior.ColorIndex = 6
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Columns("E:E").Select
Selection.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A11").Select
Selection.Interior.ColorIndex = 6
Range("B1").Select
ActiveCell.FormulaR1C1 = "ORDER"
Range("C1").Select
ActiveCell.FormulaR1C1 = "GROUP"
Range("A11").Select
Selection.Font.Bold = False
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("A11").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Columns("G:G").Select
Selection.Insert Shift:=xlToRight
Range("G1").Select
ActiveCell.FormulaR1C1 = "SIZE (TEU)"
With ActiveCell.Characters(Start:=1, Length:=10).Font
.Name = "Tahoma"
.FontStyle = "Gras"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With
Range("G4").Select
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
Columns("K:K").Select
Selection.Insert Shift:=xlToRight
Columns("L:L").Select
Selection.Insert Shift:=xlToRight
Range("K1").Select
ActiveCell.FormulaR1C1 = "MOI1"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Tahoma"
.FontStyle = "Gras"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With
Range("L1").Select
ActiveCell.FormulaR1C1 = "MOI2"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Tahoma"
.FontStyle = "Gras"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With
Columns("O:O").Select
Selection.Insert Shift:=xlToRight
Range("O1").Select
ActiveCell.FormulaR1C1 = "MOI3"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Tahoma"
.FontStyle = "Gras"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With
ActiveWorkbook.Save
End Sub
Sub Macro2()
'
' Macro2 Macro
' Macro enregistrée le 08/07/2009 par ritchy
'

'
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
Columns("K:K").Select
Selection.Insert Shift:=xlToRight
Range("K1").Select
ActiveCell.FormulaR1C1 = "MOI3"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Tahoma"
.FontStyle = "Gras"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With
Columns("L:L").Select
Selection.Insert Shift:=xlToRight
Range("L1").Select
ActiveCell.FormulaR1C1 = "MOI4"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Tahoma"
.FontStyle = "Gras"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With
Columns("M:M").Select
Selection.Insert Shift:=xlToRight
Range("M1").Select
ActiveCell.FormulaR1C1 = "MOI5"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Tahoma"
.FontStyle = "Gras"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With
Range("M5").Select
End Sub

Private Sub CommandButton4_Click()

Macro1
Macro2


End Sub
 

Dranreb

XLDnaute Barbatruc
Bonjour.
La réponse de Pierrot93 s'applique à un bouton ActiveX nommé CommandButton1, et le code doit être mis dans le module de la feuille le contenant.
S'il s'agit d'un bouton de formulaire le code doit être mis dans un module standard et la procédure, qui ne doit pas être Private, doit être affectée au bouton.
 

Discussions similaires

Réponses
2
Affichages
217
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…