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
|
Option Explicit
Public compte_false As Integer
Public compte_miss As Integer
Sub Controle_données()
Dim Nb_ligne As Long, i As Long
Dim n As Long
Dim k As Long
k = 1
Feuil6.Cells.ClearFormats
Feuil6.Cells.ClearContents
Application.ScreenUpdating = False
With Feuil1
Nb_ligne = .Cells(.Rows.Count, 1).End(xlUp).Row
With .Rows("2:" & Nb_ligne)
.ClearComments
.ClearFormats
End With
compte_false = 0
compte_miss = 0
For i = 2 To Nb_ligne
'Tar pM
n = Len(.Cells(i, 3).Value)
If n > 3 Then
.Cells(i, 3).Interior.Color = RGB(0, 0, 0)
.Cells(i, 3).Font.Color = RGB(255, 255, 255)
.Cells(i, 3).Font.Bold = True
.Cells(i, 3).AddComment
.Cells(i, 3).Comment.Text Text:="Il ne doit pas y avoir plus de 3 caractère dans cette cellule"
compte_false = compte_false + 1
End If
'colonne Log N
If .Cells(i, 5) <> "C" And .Cells(i, 5) <> "S" And .Cells(i, 5) <> "G" And .Cells(i, 5) <> "" Then
.Cells(i, 5).Interior.Color = RGB(0, 0, 0)
.Cells(i, 5).Font.Color = RGB(255, 255, 255)
.Cells(i, 5).Font.Bold = True
.Cells(i, 5).AddComment
.Cells(i, 5).Comment.Text Text:="Les caractères acceptés sont ""C"", ""S"", ""G"" et case vides "
compte_false = compte_false + 1
End If
'colonne Cat Marché
If .Cells(i, 6) <> "" And Cells(i, 6) <> "Oui" Then
.Cells(i, 6).Interior.Color = RGB(0, 0, 0)
.Cells(i, 6).Font.Color = RGB(255, 255, 255)
.Cells(i, 6).Font.Bold = True
.Cells(i, 6).AddComment
.Cells(i, 6).Comment.Text Text:="Les caractères acceptés sont ""Oui"" et case vides "
compte_false = compte_false + 1
End If
'Vie N
If .Cells(i, 8) <> "" And Cells(i, 8) <> "F" And Cells(i, 8) <> "N" Then
.Cells(i, 8).Interior.Color = RGB(0, 0, 0)
.Cells(i, 8).Font.Color = RGB(255, 255, 255)
.Cells(i, 8).Font.Bold = True
.Cells(i, 8).AddComment
.Cells(i, 8).Comment.Text Text:="Les caractères acceptés sont ""N"" ,""F"" et case vides "
compte_false = compte_false + 1
End If
'Code article
If .Cells(i, 9) = "" Then
.Cells(i, 9).Font.ColorIndex = 3
.Cells(i, 9).Interior.ColorIndex = 6
.Cells(i, 9).Font.Bold = True
.Cells(i, 9).AddComment
.Cells(i, 9).Comment.Text Text:="Pas de cellules vides autorisées"
compte_miss = compte_miss + 1
End If
'Article
If .Cells(i, 10) = "" Then
.Cells(i, 10).Font.ColorIndex = 3
.Cells(i, 10).Interior.ColorIndex = 6
.Cells(i, 10).Font.Bold = True
.Cells(i, 10).AddComment
.Cells(i, 10).Comment.Text Text:="Pas de cellules vides autorisées"
compte_miss = compte_miss + 1
End If
'Code EAN
n = Len(.Cells(i, 13).Value)
If n <> 13 And .Cells(i, 13) <> "" Then
.Cells(i, 13).Interior.Color = RGB(0, 0, 0)
.Cells(i, 13).Font.Color = RGB(255, 255, 255)
.Cells(i, 13).Font.Bold = True
.Cells(i, 13).AddComment
.Cells(i, 13).Comment.Text Text:="Le code EAN doit comporté 13 caractères"
compte_false = compte_false + 1
End If
'Sig Pm
n = Len(Cells(i, 15).Value)
If n <> 3 And .Cells(i, 15) <> "" Then
.Cells(i, 15).Interior.Color = RGB(0, 0, 0)
.Cells(i, 15).Font.Color = RGB(255, 255, 255)
.Cells(i, 15).Font.Bold = True
.Cells(i, 15).AddComment
.Cells(i, 15).Comment.Text Text:="Sig Pm doit comporté 3 caractères"
compte_false = compte_false + 1
End If
'marché
n = Len(Cells(i, 38).Value)
If n > 1 Then
.Cells(i, 38).Interior.Color = RGB(0, 0, 0)
.Cells(i, 38).Font.Color = RGB(255, 255, 255)
.Cells(i, 38).Font.Bold = True
.Cells(i, 38).AddComment
.Cells(i, 38).Comment.Text Text:="Seulement 1 caractère pour cette cellule"
compte_false = compte_false + 1
End If
'Domaine
n = Len(Cells(i, 39).Value)
If n <> 0 And n <> 2 Then
.Cells(i, 39).Interior.Color = RGB(0, 0, 0)
.Cells(i, 39).Font.Color = RGB(255, 255, 255)
.Cells(i, 39).Font.Bold = True
.Cells(i, 39).AddComment
.Cells(i, 39).Comment.Text Text:="2 caractères pour cette cellule"
compte_false = compte_false + 1
End If
'If Rows(i) <> RGB(255, 255, 255) Then
'Feuil6.Cells(k, 1).Value = i
'k = k + 1
'End If
n = 1
Do
If Cells(i, n).Interior.Color <> RGB(255, 255, 255) Then
With Feuil6
.Cells(k, 1).Value = i
End With
k = k + 1
Exit Do
Else
n = n + 1
End If
Loop Until n = 42
Application.StatusBar = "Patientez: traitement effectuer à " & Int(100 * i / Nb_ligne) & " %"
Next i
End With
Application.StatusBar = False
Feuil6.Activate
If Cells(1, 1) <> "" Then
Call misenforme
End If
Application.ScreenUpdating = True
End Sub |
Partager