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
| Function checkRow(ws As Worksheet, rw As Long) As String
Dim result As String ' Recevra la liste des colonnes en erreur (lettre de la colonne)
Dim zone As String
Dim cel As Range
Dim contenu As String
result = ""
cl = 1
zone = "A" & rw & ":" & ColumnLetter(LstColumn(ws, 2)) & rw
ws.Range(zone).Interior.ColorIndex = xlNone ' Avant de contrôler la ligne, j'enlève les éventuelles couleur.
chkval = ws.Cells(rw, 1) ' primary key (utilisé lors de l'importation dans une base de donnée). Par confidentialité, je ne peux pas en dire plus.
p = InStr(1, chkval, "//")
zone = "B" & rw & ":" & ColumnLetter(LstColumn(ws, 2)) & rw ' Zone des données sans la primary key
' Je compte si toutes les cellules contient une valeur. Si c'est le cas, c'est bon. Je sort de la fonction.
If WorksheetFunction.CountA(ws.Range(zone)) = 0 Then
ws.Cells(rw, 1).Interior.ColorIndex = xlNone
Else
' Je contrôle la validité de la primary key
If p > 0 Or Right(chkval, 1) = "/" Then
ws.Cells(rw, 1).Interior.ColorIndex = 40
Else
ws.Cells(rw, 1).Interior.ColorIndex = xlNone
End If
' Je parcours chaque cellule
For Each cel In ws.Range(zone)
contenu = CStr(cel.Value)
' Je recherche, pour certaines cellules, qu'elles soient remplie avec une valeur particulière.
'
If contenu = "" Or IsNull(contenu) Then
If (cel.Column <> 6 And cel.Column <> 7 And cel.Column <> 8 And cel.Column <> 13 And cel.Column <> 16 And cel.Column <> 18 And cel.Column <> 19 And cel.Column <> 20 And cel.Column <> 21 And cel.Column <> 25 And cel.Column <> 27 And cel.Column <> 28 And cel.Column <> 29 And cel.Column <> 31 And cel.Column <> 32 And cel.Column <> 33 And cel.Column <> 34 And cel.Column <> 35 And cel.Column < 38) Then
If cel.Column = 23 Then
If Left(cel.Offset(0, -9), 7) = "Pending" Then
cel.Value = "N/A"
End If
ElseIf cel.Column = 36 Then
If cel.Offset(0, -21) = "Rejected" Then
result = result & " AJ,"
cel.Interior.ColorIndex = 40
End If
ElseIf cel.Column = 37 Then
If cel.Offset(0, -8) = "YES" Then
result = result & " AK,"
cel.Interior.ColorIndex = 40
End If
Else
result = result & ColumnLetter(cel.Column) & ","
cel.Interior.ColorIndex = 40
End If
End If
End If
cl = cl + 1
Next cel
End If
If Len(result) > 0 Then
checkRow = Left(result, Len(result) - 1) ' J'enlève la dernière virgule de la liste
Else
checkRow = ""
End If
End Function |
Partager