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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
|
Sub ScoringUpdater()
Dim nbJan As Integer, nbFeb As Integer, nbApr As Integer, nbMar As Integer, nbMay As Integer
Dim nbJun As Integer, nbJul As Integer, nbAug As Integer, nbSep As Integer, nbOct As Integer
Dim nbNov As Integer, nbDec As Integer, nbTotal As Integer
Dim sumJan As Long, sumFeb As Long, sumApr As Long, sumMar As Long, sumMay As Long
Dim sumJun As Long, sumJul As Long, sumAug As Long, sumSep As Long, sumOct As Long
Dim sumNov As Long, sumDec As Long, sumTotal As Long
Dim lastlign As Integer
Dim ligTab As Integer
Dim ActualYear As Integer
Dim cursorPerson As Integer
Dim rCell As Range
'store the lenght of the table from "Scoring Updater"
ligTab = Worksheets("Scoring Updater").Range("A" & Rows.Count).End(xlUp).Row
nbJan = 0
nbFeb = 0
nbMar = 0
nbApr = 0
nbMay = 0
nbJun = 0
nbJul = 0
nbAug = 0
nbSep = 0
nbOct = 0
nbNov = 0
nbDec = 0
nbTotal = 0
sumJan = 0
sumFeb = 0
sumMar = 0
sumApr = 0
sumMay = 0
sumJun = 0
sumJul = 0
sumAug = 0
sumSep = 0
sumOct = 0
sumNov = 0
sumDec = 0
myTotal = 0
'store the actual year
ActualYear = Year(Date)
Worksheets("Scoring Updater").Range("A1").Value = ActualYear
cursorPerson = 0
'find and place the number of update per month
For Each rCell In Worksheets("Scoring Updater").Range("A4:A" & ligTab)
For i = 2 To lastlign
If IsDate(Worksheets("All").Range("G" & i).Value) And IsDate(Worksheets("All").Range("L" & i).Value) And Year(Worksheets("All").Range("G" & i).Value) = ActualYear Then
If rCell = Worksheets("All").Range("K" & i).Value Then
Select Case Month(Worksheets("All").Range("G" & i).Value)
Case 1
nbJan = nbJan + 1
sumJan = (Worksheets("All").Range("L" & i).Value - Worksheets("All").Range("G" & i).Value) + sumJan
' nbTotal = nbTotal + 1
Case 2
nbFeb = nbFeb + 1
sumFev = (Worksheets("All").Range("L" & i) - Worksheets("All").Range("G" & i)) + sumFev
'nbTotal = nbTotal + 1
Case 3
nbMar = nbMar + 1
sumMar = (Worksheets("All").Range("L" & i) - Worksheets("All").Range("G" & i)) + sumMar
' nbTotal = nbTotal + 1
Case 4
nbApr = nbApr + 1
sumApr = sumApr + (Worksheets("All").Range("L" & i) - Worksheets("All").Range("G" & i))
'nbTotal = nbTotal + 1
Case 5
nbMay = nbMay + 1
sumMay = sumMay + (Worksheets("All").Range("L" & i) - Worksheets("All").Range("G" & i))
'nbTotal = nbTotal + 1
Case 6
nbJun = nbJun + 1
sumJun = (Worksheets("All").Range("L" & i) - Worksheets("All").Range("G" & i)) + sumJun
' nbTotal = nbTotal + 1
Case 7
nbJul = nbJul + 1
sumJul = sumJul + (Worksheets("All").Range("L" & i) - Worksheets("All").Range("G" & i))
' nbTotal = nbTotal + 1
Case 8
nbAug = nbAug + 1
sumAug = sumAug + (Worksheets("All").Range("L" & i) - Worksheets("All").Range("G" & i))
' nbTotal = nbTotal + 1
Case 9
nbSep = nbSep + 1
sumSep = sumSep + (Worksheets("All").Range("L" & i) - Worksheets("All").Range("G" & i))
' nbTotal = nbTotal + 1
Case 10
nbOct = nbOct + 1
sumOct = (Worksheets("All").Range("L" & i) - Worksheets("All").Range("G" & i)) + sumOct
' nbTotal = nbTotal + 1
Case 11
nbNov = nbNov + 1
sumNov = (Worksheets("All").Range("L" & i) - Worksheets("All").Range("G" & i)) + sumNov
'nbTotal = nbTotal + 1
Case 12
nbDec = nbDec + 1
sumDec = (Worksheets("All").Range("L" & i) - Worksheets("All").Range("G" & i)) + sumDec
'nbTotal = nbTotal + 1
End Select
End If
End If
Next
With Worksheets("Scoring Updater").Range("B" & 4 + cursorPerson)
.Value = sumJan
' .Interior.ThemeColor = xlThemeColorAccent4
' .Interior.TintAndShade = 0.599963377788629
' .Borders.Weight = xlThin
.HorizontalAlignment = xlCenter
End With
With Worksheets("Scoring Updater").Range("D" & 4 + cursorPerson)
.Value = sumFev
' .Interior.ThemeColor = xlThemeColorAccent4
' .Interior.TintAndShade = 0.599963377788629
' .Borders.Weight = xlThin
.HorizontalAlignment = xlCenter
End With
With Worksheets("Scoring Updater").Range("F" & 4 + cursorPerson)
.Value = sumMar
' .Interior.ThemeColor = xlThemeColorAccent4
' .Interior.TintAndShade = 0.599963377788629
' .Borders.Weight = xlThin
.HorizontalAlignment = xlCenter
End With
With Worksheets("Scoring Updater").Range("H" & 4 + cursorPerson)
.Value = sumApr
' .Interior.ThemeColor = xlThemeColorAccent4
' .Interior.TintAndShade = 0.599963377788629
' .Borders.Weight = xlThin
.HorizontalAlignment = xlCenter
End With
With Worksheets("Scoring Updater").Range("J" & 4 + cursorPerson)
.Value = sumMay
' .Interior.ThemeColor = xlThemeColorAccent4
' .Interior.TintAndShade = 0.599963377788629
' .Borders.Weight = xlThin
.HorizontalAlignment = xlCenter
End With
With Worksheets("Scoring Updater").Range("L" & 4 + cursorPerson)
.Value = sumJun
' .Interior.ThemeColor = xlThemeColorAccent4
' .Interior.TintAndShade = 0.599963377788629
' .Borders.Weight = xlThin
.HorizontalAlignment = xlCenter
End With
With Worksheets("Scoring Updater").Range("N" & 4 + cursorPerson)
.Value = sumJul
' .Interior.ThemeColor = xlThemeColorAccent4
' .Interior.TintAndShade = 0.599963377788629
' .Borders.Weight = xlThin
.HorizontalAlignment = xlCenter
End With
With Worksheets("Scoring Updater").Range("P" & 4 + cursorPerson)
.Value = sumAug
' .Interior.ThemeColor = xlThemeColorAccent4
' .Interior.TintAndShade = 0.599963377788629
' .Borders.Weight = xlThin
.HorizontalAlignment = xlCenter
End With
With Worksheets("Scoring Updater").Range("R" & 4 + cursorPerson)
.Value = sumSep
' .Interior.ThemeColor = xlThemeColorAccent4
' .Interior.TintAndShade = 0.599963377788629
' .Borders.Weight = xlThin
.HorizontalAlignment = xlCenter
End With
With Worksheets("Scoring Updater").Range("T" & 4 + cursorPerson)
.Value = sumOct
' .Interior.ThemeColor = xlThemeColorAccent4
' .Interior.TintAndShade = 0.599963377788629
' .Borders.Weight = xlThin
.HorizontalAlignment = xlCenter
End With
With Worksheets("Scoring Updater").Range("V" & 4 + cursorPerson)
.Value = sumNov
' .Interior.ThemeColor = xlThemeColorAccent4
' .Interior.TintAndShade = 0.599963377788629
' .Borders.Weight = xlThin
.HorizontalAlignment = xlCenter
End With
With Worksheets("Scoring Updater").Range("X" & 4 + cursorPerson)
.Value = sumDec
' .Interior.ThemeColor = xlThemeColorAccent4
' .Interior.TintAndShade = 0.599963377788629
' .Borders.Weight = xlThin
.HorizontalAlignment = xlCenter
End With
' With Worksheets("Scoring Updater").Range("Z" & 2 + cursorPerson)
' .Value = myTotal / nbTotal
' .Interior.ThemeColor = xlThemeColorAccent4
' .Interior.TintAndShade = 0.599963377788629
' .Borders.Weight = xlThin
' .HorizontalAlignment = xlCenter
' .Font.FontStyle = "Gras"
' End With
nbJan = 0
nbFeb = 0
nbMar = 0
nbApr = 0
nbMay = 0
nbJun = 0
nbJul = 0
nbAug = 0
nbSep = 0
nbOct = 0
nbNov = 0
nbDec = 0
nbTotal = 0
cursorPerson = cursorPerson + 1
Next
ThisWorkbook.Sheets("Scoring Updater").Activate
ThisWorkbook.Sheets("Scoring Updater").Range("A1:N" & ligTab).Sort key1:=Range("N1"), order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub |
Partager