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
|
Option Explicit
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim x As Integer
Dim y As Integer
Dim Z As Integer
Dim xx As Integer
Dim vDat As Date
Dim vNom As String
Dim vEqui As String
Dim itGronde As Integer
Dim tGronde(6) As String
Dim nbLignesDonneesBrutes As Integer
Dim nbLignesGdRondes As Integer
Dim tCompteuretat() As String
Dim tCompteur() As String 'currency
Dim tCompteur2() As Variant 'currency
Dim tTitres() As String
Dim tNumeros() As String
Dim tIndic() As String
Dim tIndic2() As String
Dim tIndic3() As String
Dim compt As Integer
Sub Essai()
If MsgBox("Etes-vous certain de vouloir valider l'encodage?", vbYesNo, "Demande de confirmation") = vbYes Then
Application.ScreenUpdating = False
vDat = Sheets("Feuilles_rondes").Range("S5")
vNom = Sheets("Feuilles_rondes").Range("S3")
vEqui = Sheets("Feuilles_rondes").Range("Z5")
'recherche nombre de lignes de la feuille de ronde
Sheets("Feuilles_rondes").Activate
ActiveSheet.Unprotect
a = Range("C65536").End(xlUp).Row
b = a - 8
c = b * 10
'recherche dernière ligne de la feuille de données brutes
Sheets("Données_Brutes").Activate
ActiveSheet.Unprotect
nbLignesDonneesBrutes = Range("A65536").End(xlUp).Row + 1
'recherche dernière ligne de la feuille des données brutes grande ronde
Sheets("Données_Brutes_Grandes_rondes").Activate
ActiveSheet.Unprotect
nbLignesGdRondes = Range("A65536").End(xlUp).Row + 1
Worksheets("Feuilles_Rondes").Activate
For itGronde = 0 To 6
Cells(6, itGronde + 6).Activate
'si la couleur de fond est orange, le contenu des deux cellules situées au dessus sont stockées dans la variable tGronde
If ActiveCell.Interior.Color = 5296274 Then tGronde(itGronde) = ActiveCell.Offset(-1, 0).Value & ActiveCell.Offset(-2, 0)
' Suppression de l'information semaine pour les trois valeurs A,B et C
If Left(tGronde(itGronde), 1) = "A" Then
tGronde(itGronde) = Left(tGronde(itGronde), 1)
ElseIf Left(tGronde(itGronde), 1) = "B" Then
tGronde(itGronde) = Left(tGronde(itGronde), 1)
ElseIf Left(tGronde(itGronde), 1) = "C" Then
tGronde(itGronde) = Left(tGronde(itGronde), 1)
Else
End If
Next itGronde
ReDim tIndic(b, 9, 3) As String
ReDim tIndic2(b, 6) As String
ReDim tIndic3(b, 10) As String
ReDim tCompteuretat(b) As String
ReDim tCompteur(b, 4) As String 'currency
ReDim tCompteur2(c, 4) As Variant 'currency
ReDim tTitres(b, 2) As String
For x = 0 To b
tCompteuretat(x) = Cells(x + 8, 13).Value
tCompteur(x, 0) = Cells(x + 8, 14).Value
tTitres(x, 0) = Cells(x + 8, 4).Value
tTitres(x, 1) = Cells(x + 8, 3).Value
For y = 0 To 7
Cells(x + 8, y + 15).Activate
'si la cellule n'est pas vide
If ActiveCell.Value <> "" Then
'affecter sa valeur au premier niveau de la matrice tIndic
tIndic(x, y, 0) = Sheets("Feuilles_rondes").Cells(x + 8, y + 15).Value
'affecter le titre de la ligne au deuxieme niveau de la matrice tIndic
tIndic(x, y, 1) = Sheets("Feuilles_rondes").Cells(x + 8, 4).Value
'affecter le titre de la colonne au dernier niveau de la matrice
tIndic(x, y, 2) = Sheets("Feuilles_rondes").Cells(7, y + 15).Value
End If
Next y
Next x
'Comptage du nombre de fois X dans chaque ligne
For x = LBound(tIndic, 1) To UBound(tIndic, 1)
compt = 0
For y = LBound(tIndic, 2) To UBound(tIndic, 2) - 1
If tIndic(x, y, 0) = "" Then compt = compt
Else
tIndic3(x, compt) = tIndic(x, y, 2)
compt = compt + 1
tIndic(x, 8, 0) = compt
End If
Next y
Next x
'définition des cellules dans lesquelles rechercher les valeurs et stockage des valeurs dans la variable tableau tIndic2
For x = 0 To UBound(tIndic, 1)
If tIndic(x, 8, 0) = 3 Then
tIndic2(x, 0) = Cells(x + 8, 23).Value
tIndic2(x, 1) = Cells(x + 8, 25).Value
tIndic2(x, 2) = Cells(x + 8, 27).Value
ElseIf tIndic(x, 8, 0) = 2 Then
tIndic2(x, 0) = Cells(x + 8, 23).Value
tIndic2(x, 1) = Cells(x + 8, 26).Value
ElseIf tIndic(x, 8, 0) = 1 Then
tIndic2(x, 0) = Cells(x + 8, 23).Value
Else
End If
Next x
For x = 0 To UBound(tCompteur, 1)
For y = 1 To UBound(tCompteur, 2)
tCompteur(x, y) = tIndic2(x, y - 1)
Next y
Next x
'Z = 0
' For x = 0 To UBound(tCompteur, 1)
'For y = 0 To UBound(tCompteur, 2)
'If tIndic(x, 8, 0) = 3 Then
'tCompteur2(Z, 0) = tTitres(x, 0)
'tCompteur2(Z, 2) = tTitres(x, 1)
'tCompteur2(Z, 3) = tCompteur(x, 0)
'Z = Z + 1
'tCompteur2(Z, 1) = tIndic2(x, 3)
' tCompteur2(Z, 0) = tTitres(x, 0)
' tCompteur2(Z, 2) = tTitres(x, 1)
' tCompteur2(Z, 3) = tCompteur(x, 0)
' Z = Z + 1
' tCompteur2(Z, 1) = tIndic2(x, 4)
' tCompteur2(Z, 0) = tTitres(x, 0)
' tCompteur2(Z, 2) = tTitres(x, 1)
' tCompteur2(Z, 3) = tCompteur(x, 0)
' Z = Z + 1
' tCompteur2(Z, 1) = tIndic2(x, 5)
' tCompteur2(Z, 0) = tTitres(x, 0)
' tCompteur2(Z, 2) = tTitres(x, 1)
' tCompteur2(Z, 3) = tCompteur(x, 0)
' Z = Z + 1
' ElseIf tIndic(x, 8, 0) = 2 Then
' tCompteur2(Z, 0) = tTitres(x, 0)
' tCompteur2(Z, 2) = tTitres(x, 1)
' tCompteur2(Z, 3) = tCompteur(x, 0)
' Z = Z + 1
' tCompteur2(Z, 1) = tIndic2(x, 3)
' tCompteur2(Z, 0) = tTitres(x, 0)
' tCompteur2(Z, 2) = tTitres(x, 1)
' tCompteur2(Z, 3) = tCompteur(x, 0)
'Z = Z + 1
' tCompteur2(Z, 1) = tIndic2(x, 4)
'tCompteur2(Z, 0) = tTitres(x, 0)
' tCompteur2(Z, 2) = tTitres(x, 1)
' tCompteur2(Z, 3) = tCompteur(x, 0)
' Z = Z + 1
' ElseIf tIndic(x, 8, 0) = 1 Then
' tCompteur2(Z, 0) = tTitres(x, 0)
' tCompteur2(Z, 2) = tTitres(x, 1)
' tCompteur2(Z, 3) = tCompteur(x, 0)
' Z = Z + 1
' tCompteur2(Z, 1) = tIndic2(x, 3)
' tCompteur2(Z, 0) = tTitres(x, 0)
' tCompteur2(Z, 2) = tTitres(x, 1)
' tCompteur2(Z, 3) = tCompteur(x, 0)
' Z = Z + 1
' Else
' tCompteur2(Z, 0) = tTitres(x, 0)
' tCompteur2(Z, 2) = tTitres(x, 1)
' tCompteur2(Z, 3) = tCompteur(x, 0)
' Z = Z + 1
' End If
' Next y
' Next x
'alimentation de la feuille Données_Brutes
Sheets("Données_Brutes").Activate
Cells(nbLignesDonneesBrutes, 1) = vDat
Cells(nbLignesDonneesBrutes, 2) = vNom
Cells(nbLignesDonneesBrutes, 3) = vEqui
' For x = 0 To UBound(tCompteur2, 1)
' For y = 0 To UBound(tCompteur2, 2)
' Cells(1, 4 + x) = tCompteur2(x, 0)
' Cells(2, 4 + x) = tCompteur2(x, 2)
' Cells(3, 4 + x) = tCompteur2(x, 1)
' Cells(nbLignesDonneesBrutes, 4 + x) = tCompteur2(x, 3)
' Next y
' Next x
Sheets("Données_Brutes_Grandes_rondes").Activate
For xx = 0 To UBound(tGronde)
If vEqui = tGronde(xx) Then
Cells(nbLignesGdRondes, 1) = vDat
Cells(nbLignesGdRondes, 2) = vNom
Cells(nbLignesGdRondes, 3) = vEqui
For x = 0 To UBound(tCompteur2, 1)
For y = 0 To UBound(tCompteur2, 2)
Cells(1, 4 + x) = tCompteur2(x, 0)
Cells(2, 4 + x) = tCompteur2(x, 2)
Cells(3, 4 + x) = tCompteur2(x, 1)
Cells(nbLignesDonneesBrutes, 4 + x) = tCompteur2(x, 3)
Next y
Next x
End If
Next xx
Sheets("Déboguage").Activate
Range(Cells(1, 1), Cells(UBound(tTitres, 1), UBound(tTitres, 2))) = tTitres
Range(Cells(1, 4), Cells(UBound(tIndic2, 1), UBound(tIndic2, 2) + 4)) = tIndic2
Range(Cells(1, 10), Cells(UBound(tIndic3, 1), UBound(tIndic3, 2) + 6)) = tIndic3
'Range(Cells(1, 11), Cells(UBound(tIndic3, 1), Ubound(tIndic,2)+11) = tIndic(, , 0)
Else: MsgBox ("Encodage de ronde annulé!" & Chr(10) & " La Prochaine feuille de ronde n'est pas imprimée!")
End If ' Msgbox
End Sub |
Partager