a = 1
b = 0
d = 0
e = 0
'w = 32 'Numero de la colonne Société
'x = 27 'Numero de la colonne Priorités
'y = 28 'Numero de la colonne statut
'z = 39 'Numero de la colonne TOP REF
colSociété = 32
colPriorité = 27
colStatut = 28
colTopRef = 39
With Zone
.Cells(c + 1, colSociété) = 99189998
.Cells(c + 1, colStatut) = 9
g = Application.Match(9, .Range(Cells(1, colStatut), Cells(c + 1, colStatut)), 0)
.Cells(1, 32) = "Code Fournisseur C."
TABL = .Range(Cells(1, 1), Cells(g + 1, 45)).Value
End With
Do
a = a + 1
If (TABL(a, 1) = TABL(a - 1, 1) And TABL(a, colSociété) = TABL(a - 1, colSociété)) Or (TABL(a, 1) = TABL(a + 1, 1) And TABL(a, colSociété) = TABL(a + 1, colSociété)) Then
TABL(a, 3) = "MULTI"
If TABL(a - 1, colSociété) = TABL(a, colSociété) And TABL(a - 1, 1) = TABL(a, 1) Then
TABL(a, 4) = TABL(a - 1, 4)
Else
b = 0:d = 0
Do
b = b + 1
If TABL(a + b - 1, colPriorité) >= TABL(a + b, colPriorité) And TABL(a + b, colTopRef) = "N" Then
d = TABL(a + b, colPriorité)
Else
d = TABL(a + b - 1, colPriorité)
End If
Loop Until TABL(a + b + 1, colSociété) <> TABL(a, colSociété) Or TABL(a + b + 1, 1) <> TABL(a, 1) Or TABL(a + b + 1, colTopRef) = "O" Or (a + b + 1) = g
TABL(a, 4) = d
End If
Else
TABL(a, 3) = "MONO"
TABL(a, 4) = "ND"
End If
If TABL(a, 3) = "MONO" Or TABL(a, 4) = TABL(a, colPriorité) Or TABL(a, colTopRef) = "O" Then
TABL(a, 2) = "ok"
Else
TABL(a, 2) = "suppr"
End If
Loop Until a = g - 1
With Zone
.Range(Cells(1, 1), Cells(g + 1, 45)).Value = TABL
.Range(Cells(g, 2), Cells(c + 1, 2)).Value = "suppr"
.Range(Cells(g, 3), Cells(c + 1, 4)).Value = "ND"
.Range(Cells(c + 1, 1), Cells(c + 1, 35)).ClearContents
End With