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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
Option Compare Text
Sub Copiare()
Dim DerLig_F1 As Long, DerLig_F2 As Long, i As Long, j As Long, L As Long
Dim ROL As Long, ORD As Long, FE As Long
Dim f1 As Worksheet, f2 As Worksheet
Dim Matr As String
Application.ScreenUpdating = False
Set f1 = Sheets("Foglio2")
Set f2 = Sheets("Foglio3")
f2.Cells.Clear
DerLig_F1 = f1.[A10000].End(xlUp).Row
f1.Range(Cells(1, "A"), Cells(DerLig_F1, "C")).Copy Destination:=f2.Cells(1, "A")
Matr = Cells(1, "A")
For i = 2 To DerLig_F1
If f2.Cells(i, "A") = Matr Then
f2.Cells(i, "A") = ""
Else
Matr = Cells(i, "A")
End If
Next
f2.Select
'Formule pour récupérer le jour
Range("D1:D" & DerLig_F1).FormulaR1C1 = "=IF(RC[-1]<>"""",DATE(MID(RC[-2],3,4),MID(RC[-2],7,2),RIGHT(RC[-2],2))*1,"""")"
Columns("D:D").NumberFormat = "[$-F800]dddd, mmmm dd, yyyy"
For i = DerLig_F1 + 1 To 2 Step -1
If Format(Cells(i - 1, "D"), "dddd") = "Vendredi" Then
If Cells(i, "B") <> "" Then Rows(i & ":" & i + 1).Insert Shift:=xlDown
Cells(i, "D") = Cells(i - 1, "D") + 1
Cells(i, "B") = Year(Cells(i, "D")) & Format(Month(Cells(i, "D")), "00") & Format(Day(Cells(i, "D")), "00")
Cells(i + 1, "D") = (Cells(i, "D") + 1) * 1
Cells(i + 1, "B") = Year(Cells(i + 1, "D")) & Format(Month(Cells(i + 1, "D")), "00") & Format(Day(Cells(i + 1, "D")), "00")
Range(Cells(i, "C"), Cells(i + 1, "C")) = "R000000"
With Range(Cells(i, "B"), Cells(i + 1, "C")).Font
.Name = "Calibri"
.Size = 11
.ColorIndex = 1
End With
End If
Next i
DerLig_F2 = [B10000].End(xlUp).Row
For i = DerLig_F2 To 2 Step -1
ROL = 0
ORD = 0
FE = 0
L = i
For j = L To 1 Step -1
Select Case Left(Cells(L, "C"), 1)
Case Is = "R"
ROL = ROL + Right(Cells(L, "C"), 6) * 1
Case Is = "O"
ORD = ORD + Right(Cells(L, "C"), 6) * 1
Case Is = "F"
FE = FE + Right(Cells(L, "C"), 6) * 1
End Select
If Cells(L, "A") <> "" Then Exit For
L = L - 1
Next j
If i <> DerLig_F2 Then Rows(i + 2 & ":" & i + 4).Insert Shift:=xlDown
If i = DerLig_F2 Then
Cells(i + 1, "B") = "ROL"
Cells(i + 1, "C") = ROL
Cells(i + 2, "B") = "ORD"
Cells(i + 2, "C") = ORD
Cells(i + 3, "B") = "FE"
Cells(i + 3, "C") = FE
Else
Cells(i + 2, "B") = "ROL"
Cells(i + 2, "C") = ROL
Cells(i + 3, "B") = "ORD"
Cells(i + 3, "C") = ORD
Cells(i + 4, "B") = "FE"
Cells(i + 4, "C") = FE
End If
i = L - 1
Next i
For i = 1 To DerLig_F2
If Cells(i, "A") <> "" Then
Matr = Cells(i, "A")
Rows(i).Insert Shift:=xlDown
Cells(i, "B") = Matr
With Cells(i, "B").Font
.Name = "Calibri"
.Size = 11
.ColorIndex = 3
End With
i = i + 1
End If
Next
Range("A:A,D:D").Delete Shift:=xlToLeft
End Sub |
Partager