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
| Sub PPréaliséspardomaine()
Dim sm, support, rth As Integer
Dim i As Integer, j, n, k, ligne As Integer, d, dd As Date, aa As Date
Dim source_SMS As Workbook
Dim classeurpardomaine As Workbook
On Error Resume Next
'Ouvrir le fichier
Set source_SMS = Workbooks.Open(FileName:="C:\Users\\Desktop\Modèle stat\Suivi de réalisation des visites de PP SM 2016.xlsx")
'initialisation des variables à 0
ligne = 0 'nombre de ligne
sm = 0 'somme des opérations de SM
support = 0 'somme des opération de SUPPORT
rth = 0 'somme des opérations de RTH
For i = 6 To Range("M1048576").End(xlUp).Row
Dim mois As String
mois = Format(Date, "mmmm")
dd = Cells(i, 13).Value
If IsDate(dd) = True Then
If Month(dd) = Month(Date) And Year(dd) = Year(Date) Then
If Cells(i, 13).Value <> "" Then
sm = sm + 1
End If
End If
End If
Next
'fermeture du fichier
source_SM.Close False
'Ouvrir le fichier
Set classeurpardomaine = Workbooks.Open(FileName:="\\mv0\Stagia\Stag\projet\Automatisation BDD PP\Documents\Développement\Futur Environnement\Statistique de gestion des PP.xlsx"
Sheets("NB DE PP Réalisés par domaine").Activate
Dim m, x As Integer
Dim valdate As Integer
'boucle for parcourant les colonnes pour trouver le mois et l'année en cours
For m = 2 To 13
valdate = Cells(1, m).Value
If Month(valdate) = Month(Date) And Year(valdate) = Year(Date) Then
'boucle for parcourant les lignes
For x = 2 To 5
If Cells(x, 1).Value = "SM" Then
Cells(x, m).Value = sms
End If
Next
'total des cellules
Cells(5, m).Value = sm
Cells(5, m).Font.Color = RGB(252, 152, 4)
x = x + 1
End If
Next
End Sub |
Partager