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
|
Private Sub CommandButton3_Click()
Dim Datedebut As Date, Datefin As Date
Datedebut = Format(DTPicker1.Value, "dd/mm/yyyy")
Datefin = Format(DTPicker2.Value, "dd/mm/yyyy")
' Dans le cas où le choix est effectué sur le DTPicker1
If Datefin < Datedebut Then
Select Case MsgBox("La date de fin ne peut être inférieure à la date de début", vbOKOnly + vbCritical, "Saisie date incorrect")
Case vbOKOnly
Exit Sub
End Select
Else
ListBox1.Clear
Dim i As Integer
With ListBox1
.Clear
.ColumnCount = 2
.ColumnWidths = "50;0"
End With
With Sheets("Modifier")
' Si le statut est "En cours" ou "Attente chgt" alors on affiche la commande dans l'écran de suivi
For i = 5 To .Range("a100000").End(xlUp).Row
If .Cells(i, 15) >= Datedebut And .Cells(i, 15) <= Datefin Then
'Si pas de quai et "Attente chgt"
If .Cells(i, 11) = "" And .Cells(i, 17) = "Attente chgt" Then
ListBox1.AddItem
ListBox1.List(ListBox1.ListCount - 1, 0) = " " & " " & .Cells(i, 17) & " " & .Cells(i, 1) & " " & .Cells(i, 15) & " " & Sheets("Formulaire").Cells(i, 3) & " " & .Cells(i, 3) & " " & .Cells(i, 4)
Else
'si pas de quai et "En cours"
If .Cells(i, 11) = "" And .Cells(i, 17) = "En cours" Then
ListBox1.AddItem
ListBox1.List(ListBox1.ListCount - 1, 0) = " " & " " & .Cells(i, 17) & " " & .Cells(i, 1) & " " & .Cells(i, 15) & " " & Sheets("Formulaire").Cells(i, 3) & " " & .Cells(i, 3) & " " & .Cells(i, 4)
Else
'si quai et "Attente chgt"
If .Cells(i, 17) = "Attente chgt" Then
ListBox1.AddItem
ListBox1.List(ListBox1.ListCount - 1, 0) = .Cells(i, 11) & " " & .Cells(i, 17) & " " & .Cells(i, 1) & " " & .Cells(i, 15) & " " & Sheets("Formulaire").Cells(i, 3) & " " & .Cells(i, 3) & " " & .Cells(i, 4)
Else
'si quai et "En cours"
If .Cells(i, 17) = "En cours" Then
ListBox1.AddItem
ListBox1.List(ListBox1.ListCount - 1, 0) = .Cells(i, 11) & " " & .Cells(i, 17) & " " & .Cells(i, 1) & " " & .Cells(i, 15) & " " & Sheets("Formulaire").Cells(i, 3) & " " & .Cells(i, 3) & " " & .Cells(i, 4)
End If
End If
End If
End If
End If
Next i
End With
'Dim x As Range
'
' With ListBox1
' For Each x In Feuil1.Range("O5:O" & Range("O100000").End(xlUp).Row)
'
' If x.Value >= Datedebut And x.Value <= Datefin Then
'
' .AddItem x(1, -4)
' .List(.ListCount - 1, 1) = x(1, -3)
' .List(.ListCount - 1, 2) = x(1, -2)
' .List(.ListCount - 1, 3) = x(1, -1)
' .List(.ListCount - 1, 4) = x(1, 0)
' .List(.ListCount - 1, 5) = x(1, 1)
' .List(.ListCount - 1, 6) = x(1, 2)
'
' End If
' Next x
' End With
End If
End Sub |
Partager