Bonjour,
j'aide la personne qui organise le planning de mon boulot à faire un fichier pour cela.
J'ai fait une macro pour faire un calcul des horaires.
Le hic c'est que quand le code tourne j'obtiens une erreur 400 depuis que j'ai voulu appliquer un bout de code pour appliquer la macro à toutes les feuilles.
Alors voilà j'aimerai pouvoir :
- Appliquer mon code à toutes les feuilles (
- Savoir comment on peut faire pour que je puisse sélectionner une feuille en sachant qu'elle s'appelle sem1, sem2....sem52. Est ce possible de faire quelque chose pour que l'on puisse avoir par exemple :
et donc remplacer mon et là le i par quelque chose qui renverrait vers sem1 ou 2.
Voici tout mon code
Merci d'avance si vous pouvez m'aider à voir comment résoudre mon problème et comment.
P.S : Le code marchait parfaitement avant de le mettre dans This.Workbook et de tenter de l'appliquer à toutes les feuilles.
j'aide la personne qui organise le planning de mon boulot à faire un fichier pour cela.
J'ai fait une macro pour faire un calcul des horaires.
Le hic c'est que quand le code tourne j'obtiens une erreur 400 depuis que j'ai voulu appliquer un bout de code pour appliquer la macro à toutes les feuilles.
Alors voilà j'aimerai pouvoir :
- Appliquer mon code à toutes les feuilles (
Code:
For a = 1 To Sheets.Count
ActiveSheet.Select
Code:
For i = 1 to 52
Sheet(sem et là le i ).select
Voici tout mon code
Code:
Sub Macro1()
For a = 1 To Sheets.Count
ActiveSheet.Select
a = 2
b = 2
Calcul:
Range(Cells(a, b), Cells(a, b + 18)).Select
If Cells(a, b) = "D" And Cells(a, b + 9) = "" Then D = D - 1
If Cells(a, b + 18) = "D" And Cells(a, b) = "" Then D = D - 1
If Cells(a, b) = "D" And Cells(a, b + 9) = "D" Then D = D - 0.5
If Cells(a, b) = "C" And Cells(a, b + 9) = "" Then C = C - 1
If Cells(a, b + 18) = "C" And Cells(a, b) = "" Then C = C - 1
If Cells(a, b) = "C" And Cells(a, b + 9) = "C" Then C = C - 0.5
If Cells(a, b) = "L" And Cells(a, b + 9) = "" Then L = L - 1
If Cells(a, b + 18) = "L" And Cells(a, b) = "" Then L = L - 1
If Cells(a, b) = "L" And Cells(a, b + 9) = "L" Then L = L - 0.5
If Cells(a, b) = "E" And Cells(a, b + 9) = "" Then E = E - 1
If Cells(a, b + 18) = "E" And Cells(a, b) = "" Then E = E - 1
If Cells(a, b) = "E" And Cells(a, b + 9) = "D" Then E = E - 0.5
If Cells(a, b) = "K" And Cells(a, b + 9) = "" Then K = K - 1
If Cells(a, b + 18) = "K" And Cells(a, b) = "" Then K = K - 1
If Cells(a, b) = "K" And Cells(a, b + 9) = "K" Then K = K - 0.5
If Cells(a, b) = "P" And Cells(a, b + 9) = "" Then P = P - 1
If Cells(a, b + 18) = "P" And Cells(a, b) = "" Then P = P - 1
If Cells(a, b) = "P" And Cells(a, b + 9) = "P" Then P = P + 0.5
If Cells(a, b) = "M" And Cells(a, b + 9) = "" Then M = M - 1
If Cells(a, b + 18) = "M" And Cells(a, b) = "" Then M = M - 1
If Cells(a, b) = "M" And Cells(a, b + 9) = "M" Then M = M + 0.5
If Cells(a, b) = "S" And Cells(a, b + 9) = "" Then S = S - 1
If Cells(a, b + 18) = "S" And Cells(a, b) = "" Then S = S - 1
If Cells(a, b) = "S" And Cells(a, b + 9) = "S" Then S = S + 0.5
If Cells(a, b) = "J" And Cells(a, b + 9) = "" Then J = J - 1
If Cells(a, b + 18) = "J" And Cells(a, b) = "" Then J = J - 1
If Cells(a, b) = "J" And Cells(a, b + 9) = "J" Then J = J + 0.5
If Cells(a, b) = "G" And Cells(a, b + 9) = "" Then G = G - 1
If Cells(a, b + 18) = "G" And Cells(a, b) = "" Then G = G - 1
If Cells(a, b) = "G" And Cells(a, b + 9) = "G" Then G = G + 0.5
For Each Cell In Selection
If Cell.Value = "D" Then D = D + 1
If Cell.Value = "C" Then C = C + 1
If Cell.Value = "L" Then L = L + 1
If Cell.Value = "E" Then E = E + 1
If Cell.Value = "K" Then K = K + 1
If Cell.Value = "P" Then P = P + 1
If Cell.Value = "M" Then M = M + 1
If Cell.Value = "S" Then S = S + 1
If Cell.Value = "J" Then J = J + 1
If Cell.Value = "G" Then G = G + 1
Next
If Cells(a, b + 9) = "" And Cells(a, b + 10) = "D" Then D = D + 0.25
If Cells(a, b + 9) = "" And Cells(a, b + 10) = "C" Then C = C + 0.25
If Cells(a, b + 9) = "" And Cells(a, b + 10) = "L" Then L = L + 0.25
If Cells(a, b + 9) = "" And Cells(a, b + 10) = "E" Then E = E + 0.25
If Cells(a, b + 9) = "" And Cells(a, b + 10) = "K" Then K = K + 0.25
If Cells(a, b + 9) = "" And Cells(a, b + 10) = "P" Then P = P + 0.25
If Cells(a, b + 9) = "" And Cells(a, b + 10) = "M" Then M = M + 0.25
If Cells(a, b + 9) = "" And Cells(a, b + 10) = "S" Then S = S + 0.25
If Cells(a, b + 9) = "" And Cells(a, b + 10) = "J" Then J = J + 0.25
If Cells(a, b + 9) = "" And Cells(a, b + 10) = "G" Then G = G + 0.25
Cells(a, b + 19) = D
Cells(a, b + 20) = C
Cells(a, b + 21) = L
Cells(a, b + 22) = E
Cells(a, b + 23) = K
Cells(a, b + 24) = P
Cells(a, b + 25) = M
Cells(a, b + 26) = S
Cells(a, b + 27) = J
Cells(a, b + 28) = G
D = 0
C = 0
L = 0
E = 0
K = 0
P = 0
M = 0
S = 0
J = 0
G = 0
a = a + 1
If a = 41 Then GoTo Total
GoTo Calcul
GoTo Total
Total:
Range("U45").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-43]C:R[-5]C)"
Range("V45").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-43]C:R[-5]C)"
Range("W45").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-43]C:R[-5]C)"
Range("X45").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-43]C:R[-5]C)"
Range("Y45").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-43]C:R[-5]C)"
Range("Z45").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-43]C:R[-5]C)"
Range("AA45").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-43]C:R[-5]C)"
Range("AB45").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-43]C:R[-5]C)"
Range("AC45").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-43]C:R[-5]C)"
Range("AD45").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-43]C:R[-5]C)"
Next a
End Sub
Merci d'avance si vous pouvez m'aider à voir comment résoudre mon problème et comment.
P.S : Le code marchait parfaitement avant de le mettre dans This.Workbook et de tenter de l'appliquer à toutes les feuilles.