Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Une macro pour executer plusieurs macros?

13 réponses
Avatar
Pierre
Bonsoir
je me permet de vous resolliciter devant l'efficacité de vos conseils.
Je me retrouve avec un classeur d'une quinzaine de feuilles, à chaque
feuille étant affectée une macro (graphique, forme conditionnelle).
Est on obligé de lancer ces macros feuille par feuille ou est il possible de
les lancer toutes par une commande globale?
merci
Pierre

3 réponses

1 2
Avatar
Jacquouille
Holà, Paix mes Frères.
On voit que le forum commence à bien se tenir et que les envies de "Botter
le cul" vous démangent.
Pierre a fait amende (bravo pour l'humour destiné au flic) honnorable en
prenant la peine de m'écrire.-))
Je précise que je ne me sens nullement blessé ni vexé.
---------------
In texto:
Bonjour Désolé si je vous ai froissé.
çà ne se voulait pas une réponse sèche mais juste concise.
Il est vrai que je n'y entend pas grand chose.
Merci quand même
Pierre
------------------

Pour la macro, on pourrait voir un truc du genre:
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count .....si c'est
pareil pour toutes les feuilles, on peut définir une seule fois toutes les
var.
Ensuite, appeler les feuilles une à une, puis définir l'action, de manière à
ne faire qu'une macro.
Bonne chance
--
Bien amicalmement,
Vivement conseillés:
http://www.excelabo.net
http://jacxl.free.fr/mpfe/trombino.html
http://dj.joss.free.fr/netiquet.htm
http://frederic.sigonneau.free.fr/

Jacquouille.

"Pierre" a écrit dans le message de news:
FWFYg.15$
Bonjour et merci
Mais le classeur est trop volumineux
Il s'agit d'un ensemble de feuilles dont chacune contient un graphique
avec en abcisse la valeur d'un parametre (tests physiques) et en ordonnée
les noms des joueurs.
Chaque graphique est affecté d'une macro qui donne aux barres une couleur
jaune si = ou meilleur que la valeur de reference, rouge si moins bon
(exemple: la premiere macro ci dessous concerne la masse grasse qui ne
doit pas depasser 19%)
Comme ce classeur ne sera pas utilisé que par moi, j'aurais aimé qu'il
soit possible de lancer tres simplement toutes les macros d'un coup, et
surtout sans risque d'erreur (une macro pour une autre, ce qui fausse le
code couleur)
Ci dessous l'ensemble des macros tel que le montre Visual Basic Editor
Pour finir je ne maitrise pas du tout, tout ce que je sais faire c'est
d'appliquer à la lettre les conseils.
Pierre

Sub FormatConditionnelGraphiqueMG()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep > 19 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueMG2()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep > 13 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueCMJ()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 42 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueSJ()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 1140 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphique10m()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 18 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphique20m()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 21.3 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphique40m()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 24.8 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueDS()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 160 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueS()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 130 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueDC()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 120 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueEp()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 110 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueTr()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 300 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueG()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 270 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiquePh()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 35 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueVO2()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 51.5 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueVMA()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 14.7 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueAg()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep > 16.8 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueIMC()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 25 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub






















Avatar
Jacquouille
RE
Et pour faire simple, si on suggérait de placer la macro dans perso.xls?
Et ensuite d'ouvrir lezs feuilles une à une, bien que ce soit plus lent.
Mais on s'en fout car on a le temps...-)

--
Bien amicalmement,
Vivement conseillés:
http://www.excelabo.net
http://jacxl.free.fr/mpfe/trombino.html
http://dj.joss.free.fr/netiquet.htm
http://frederic.sigonneau.free.fr/

Jacquouille.

"Jacquouille" a écrit dans le message de
news:
Holà, Paix mes Frères.
On voit que le forum commence à bien se tenir et que les envies de "Botter
le cul" vous démangent.
Pierre a fait amende (bravo pour l'humour destiné au flic) honnorable en
prenant la peine de m'écrire.-))
Je précise que je ne me sens nullement blessé ni vexé.
---------------
In texto:
Bonjour Désolé si je vous ai froissé.
çà ne se voulait pas une réponse sèche mais juste concise.
Il est vrai que je n'y entend pas grand chose.
Merci quand même
Pierre
------------------

Pour la macro, on pourrait voir un truc du genre:
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count .....si c'est
pareil pour toutes les feuilles, on peut définir une seule fois toutes les
var.
Ensuite, appeler les feuilles une à une, puis définir l'action, de manière
à ne faire qu'une macro.
Bonne chance
--
Bien amicalmement,
Vivement conseillés:
http://www.excelabo.net
http://jacxl.free.fr/mpfe/trombino.html
http://dj.joss.free.fr/netiquet.htm
http://frederic.sigonneau.free.fr/

Jacquouille.

"Pierre" a écrit dans le message de news:
FWFYg.15$
Bonjour et merci
Mais le classeur est trop volumineux
Il s'agit d'un ensemble de feuilles dont chacune contient un graphique
avec en abcisse la valeur d'un parametre (tests physiques) et en ordonnée
les noms des joueurs.
Chaque graphique est affecté d'une macro qui donne aux barres une couleur
jaune si = ou meilleur que la valeur de reference, rouge si moins bon
(exemple: la premiere macro ci dessous concerne la masse grasse qui ne
doit pas depasser 19%)
Comme ce classeur ne sera pas utilisé que par moi, j'aurais aimé qu'il
soit possible de lancer tres simplement toutes les macros d'un coup, et
surtout sans risque d'erreur (une macro pour une autre, ce qui fausse le
code couleur)
Ci dessous l'ensemble des macros tel que le montre Visual Basic Editor
Pour finir je ne maitrise pas du tout, tout ce que je sais faire c'est
d'appliquer à la lettre les conseils.
Pierre

Sub FormatConditionnelGraphiqueMG()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep > 19 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueMG2()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep > 13 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueCMJ()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 42 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueSJ()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 1140 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphique10m()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 18 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphique20m()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 21.3 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphique40m()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 24.8 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueDS()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 160 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueS()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 130 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueDC()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 120 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueEp()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 110 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueTr()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 300 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueG()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 270 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiquePh()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 35 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueVO2()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 51.5 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueVMA()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 14.7 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueAg()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep > 16.8 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub
Sub FormatConditionnelGraphiqueIMC()
For c = 1 To ActiveChart.SeriesCollection.Count
For d = 1 To ActiveChart.SeriesCollection(c).Points.Count
With ActiveChart.SeriesCollection(c)
rep = Application.WorksheetFunction.Index(.Values, d)
If rep < 25 Then
.Points(d).Interior.ColorIndex = 22
Else
.Points(d).Interior.ColorIndex = 19
End If
End With
Next d
Next c
End Sub


























Avatar
Francois L
Bonjour et merci
Mais le classeur est trop volumineux
Il s'agit d'un ensemble de feuilles dont chacune contient un graphique avec
en abcisse la valeur d'un parametre (tests physiques) et en ordonnée les
noms des joueurs.
Chaque graphique est affecté d'une macro qui donne aux barres une couleur
jaune si = ou meilleur que la valeur de reference, rouge si moins bon
(exemple: la premiere macro ci dessous concerne la masse grasse qui ne doit
pas depasser 19%)
Comme ce classeur ne sera pas utilisé que par moi, j'aurais aimé qu'il soit
possible de lancer tres simplement toutes les macros d'un coup, et surtout
sans risque d'erreur (une macro pour une autre, ce qui fausse le code
couleur)



Bonsoir,

Indépendamment d'autres propositions plus sophistiquées, et des
explications de Michel Gaboly, il serait simple de lancer toutes les
macros à partir d'une seule liée par exemple à un bouton si chaque macro
définissait l'ActiveChart autrement dit, il y a une ligne à rajouter à
chaque macro.
Pour te donner la ligne en question, il faudrait savoir si les
graphiques sont tous dans la même feuille de travail, chacun dans une
feuille de travail différente, dans des feuilles graphiques, une
combinaison de tout cela ?

--
François L

1 2