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
| Private Sub UserForm_Initialize()
Dim i As Integer
Dim a As Integer
Dim tblBD As Range
Dim ligne As Integer
a = 6
Set principal = ThisWorkbook
Sheets("Liste des pièces").Select
Do While Range("C" & a) <> ""
If Range("J" & a).Value < Range("K" & a).Value Then
Range("AH" & a).Value = "CRITIQUE"
ElseIf Range("J" & a).Value > Range("AG" & a).Value Then
Range("AH" & a).Value = "CONFORTABLE"
ElseIf Range("K" & a).Value < Range("J" & a).Value < Range("AG" & a).Value Then
Range("AH" & a).Value = "URGENT"
End If
a = a + 1
Loop
With Me.ListView1
With .ColumnHeaders
.Clear
.Add , , "Désignation", 112
.Add , , "Référence", 112
.Add , , "Quantité", 112
.Add , , "Stock minimum", 112
.Add , , "Point de Cmd", 112
.Add , , "Etat du stock", 112
End With
.Gridlines = True
ListView1.View = lvwReport
tblBD = Range("A6:AH" & [A65000].End(xlUp).Row).Value
ligne = 0
For i = 1 To UBound(tblBD)
ligne = ligne + 1
.ListItems.Add , , tblBD(i, 1) 'désignation
.ListItems(ligne).ListSubItems.Add , , tblBD(i, 3) 'Référence
.ListItems(ligne).ListSubItems.Add , , tblBD(i, 10) 'Quantité
.ListItems(ligne).ListSubItems.Add , , tblBD(i, 11) 'Stock mini
.ListItems(ligne).ListSubItems.Add , , tblBD(i, 33) 'Point de commande
.ListItems(ligne).ListSubItems.Add , , tblBD(i, 34) 'Etat du stock
Next
End With
For x = 1 To ListView1.ListItems.Count
If ListView1.ListItems(x).ListSubItems(5).Text = "CONFORTABLE" Then
ListView1.ListItems(x).ListSubItems(5).ForeColor = RGB(0, 160, 0) 'vert
End If
If ListView1.ListItems(x).ListSubItems(5).Text = "CRITIQUE" Then
ListView1.ListItems(x).ListSubItems(5).ForeColor = RGB(224, 96, 0) 'orange
End If
If ListView1.ListItems(x).ListSubItems(5).Text = "URGENT" Then
ListView1.ListItems(x).ListSubItems(5).ForeColor = RGB(255, 0, 0) 'rouge
End If
If ListView1.ListItems(x).ListSubItems(5).Text = "" Then
ListView1.ListItems(x).ListSubItems(5).ForeColor = xlNone
End If
Next x
End Sub |