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
| Sub PMI()
'##############Définition des colonnes en format dates#####################
Dim i As Long
Dim stock As Date
fin = Range("A3").End(xlDown).Row
'##############Définition des colonnes en format dates#####################
Columns("D:E").Select
Selection.NumberFormat = "dd/MM/yyyy"
Columns("F").Select
Selection.NumberFormat = "General"
'###############Transformation de la périodicité en jours##################
For i = 3 To fin
Cells(i, 6).Select
If Cells(i, 6).Value = "4 Ans" Then
Cells(i, 6).Value = "1460"
End If
If Cells(i, 6).Value = "3 Ans" Then
Cells(i, 6).Value = "1095"
End If
If Cells(i, 6).Value = "2 Ans" Then
Cells(i, 6).Value = "730"
End If
If Cells(i, 6).Value = "1 Ans" Then
Cells(i, 6).Value = "365"
End If
If Cells(i, 6).Value = "18 Mois" Then
Cells(i, 6).Value = "548"
End If
If Cells(i, 6).Value = "6 Mois" Then
Cells(i, 6).Value = "183"
End If
If Cells(i, 6).Value = "4 Mois" Then
Cells(i, 6).Value = "122"
End If
Next i
'############### Réécriture de la date prochaine ##################
For i = 3 To fin
Cells(i, 5).Select
Cells(i, 4).Select
Cells(i, 6).Select
If Cells(i, 5).Value = "-" Then
Cells(i, 5).Value = Application.Sum(Cells(i, 4).Value, Cells(i, 6).Value)
End If
Next i
'############### Définition de l'intervalle de travail ##################
Const PR = vbLf & vbLf & "Entrer la date de ", TI = " INTERVALLE"
Dim DateDebut As Date, DateFin As Date, Dstock As Date
D = InputBox(PR & "début :", TI, "01/01/" & Year(Now))
If IsDate(D) Then DateDebut = D Else Exit Sub
D = InputBox(PR & "fin :", TI, D): If IsDate(D) Then DateFin = D
If DateFin < DateDebut Then Beep: Exit Sub
Application.ScreenUpdating = False
For R = Cells(Rows.Count, 5).End(xlUp).Row To 2 Step -1
If IsDate(Cells(R, 5)) Then
Dstock = Cells(R, 5)
If Dstock < DateDebut Or Dstock > DateFin Then Rows(R).Delete
End If
Next
Application.ScreenUpdating = True
'############### Copier les données dans d'autres classeurs ##################
Dim wkDest As Workbook ' Classeur destinataire
Set wkDest = Application.Workbooks.Open("H:\BILAN TRIMESTRIEL\RETARDPMI.xlsm")
' le classeur PMI.xlsm contient ce code et est donc accessible par ThisWorkBook
ThisWorkbook.Sheets("Feuil1").Cells.Copy wkDest.Sheets(Feuil2).Range("A1")
wkDest.Close True 'Ferme en sauvant
End Sub |
Partager