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 59 60 61 62 63 64 65 66 67 68 69 70 71
| Ref.Select
For j = 87 To 124
service = Hor.Cells(j, 3)
If service = "" Then
GoTo finishcadre
End If
Ref.Range("A2:AP" & DernLigneUser).AutoFilter Field:=1, Criteria1:=service 'Range(A2:AP)
Ref.Select
DernLigneUserHor = Ref.Range("AK" & Rows.Count).End(xlUp).Row
Add = 0
For i = 3 To DernLigneUserHor
If Ref.Cells(i, 1) = Hor.Cells(j, 3) Then
If Ref.Cells(i, 17) = "JOUR" Then
If Ref.Cells(i, 41).Value = Hor.Cells(85, 3) Then
For k = j To j + Add
If Ref.Cells(i, 37) = Hor.Cells(k, 4) Then
Hor.Cells(k, 5) = Hor.Cells(k, 5) + 1
GoTo nexxtcadre
End If
Next j
If Add > 0 Then
Hor.Rows(j + Add).Insert
Hor.Select
Range(Cells(j, 3), Cells(j + Add, 3)).Merge
End If
Hor.Cells(j + Add, 4) = Ref.Cells(i, 37)
Add = Add + 1
End If
End If
End If
nexxtcadre:
Next i
finishcadre:
Next j
DernLigneHorHor = Hor.Range("D" & Rows.Count).End(xlUp).Row
For i = 85 To DernLigneHorHor
If Hor.Cells(i, 4) <> "" Then
Href = Hor.Cells(i, 4).Value
Hdeb = Left(Href, Len(Href) - 8)
Hfin = Right(Href, Len(Href) - 8)
For j = 7 To 35
If Hor.Cells(4, j) = Hdeb Then
Hor.Cells(i, j) = Hor.Cells(i, 5) + 1
'Dim alpha As Range
Set alpha = Hor.Cells(i, j).Object
'MsgBox alpha
End If
If Hor.Cells(4, j) = Hfin Then
Hor.Cells(i, j) = Hor.Cells(i, 5) + 1
'Dim beta As Range
Set beta = Hor.Cells(i, j).Object
End If
Hor.Select
Hor.Range(alpha.Address & ":" & beta.Address).Merge
Selection.Merge
Next
End If
Next |
Partager