1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| Option Compare Text
Sub Recap()
Dim DerLig_f1 As Long, DerCol_f1 As Long
Dim i As Long, f As Long, s As Long, e As Long
Dim NbEq As Long, NbSe As Long
Dim Seance As String, Equide As String, Sem As String
Dim f1
Application.ScreenUpdating = False
Set f1 = Sheets("Recap")
f1.Range("C6:N100").ClearContents
DerLig_f1 = f1.[B1000].End(xlUp).Row
DerCol_f1 = f1.[B5].End(xlToRight).Column
NbEq = 100 'DerLig_f1 - 5 'Nombre d'équidés
NbSe = DerCol_f1 + 122 'Nombre de séances augmenté du nombre de colonnes qui les précèdent
ReDim Equid(NbEq, NbSe) As String
ReDim Seanc(NbEq, NbSe) As String
ReDim Tot(NbEq, NbSe) As Long
For e = 6 To NbEq 'les équidés
If f1.Cells(e, "B") = "" Then Exit For
Equide = f1.Cells(e, "B")
For s = 3 To DerCol_f1 'les séances
Seance = f1.Cells(5, s)
Tot(e, s) = 0
For f = 1 To Sheets.Count 'les feuilles
Sem = Sheets(f).Name 'les semaines
Select Case Sem
Case Is = "S01", "S02", "S03", "S04", "S05", "S06", "S07", "S08", "S09", _
"S10", "S11", "S12", "S13", "S14", "S15", "S16", "S17", "S18", "S19", _
"S20", "S21", "S22", "S23", "S24", "S25", "S26", "S27", "S28", "S29", _
"S30", "S31", "S32", "S33", "S34", "S35", "S36", "S37", "S38", "S39", _
"S40", "S41", "S42", "S43", "S44", "S45", "S46", "S47", "S48", "S49", _
"S50", "S51", "S52", "S53"
Set Eq = Sheets(Sem).Columns("B").Find(Equide, LookIn:=xlValues, Lookat:=xlWhole) 'Recherche equidé
Set Se = Sheets(Sem).Rows(5).Find(Seance, LookIn:=xlValues, Lookat:=xlWhole) 'Recherche séance
If Not Eq Is Nothing And Not Se Is Nothing Then
Equid(e, s) = Equide
Tot(e, s) = Tot(e, s) + Sheets(Sem).Cells(Eq.Row, Se.Column)
End If
End Select
Next f
Next s
Next e
'Restitution dans tableau "Recap"
For e = 6 To NbEq
For s = 3 To DerCol_f1
If f1.Cells(e, "B") = Equid(e, s) Then f1.Cells(e, s) = Tot(e, s)
Next s
Next e
Set f1 = Nothing
End Sub |
Partager