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
| Public Function Chargement() As String
Me.Show vbModal
Dim I As Integer, Wh As String
With Me.ListBox1
For I = 0 To .ListCount - 1
If .Selected(I) = True Then
If Wh = "" Then Wh = "'" & .List(I) & "'" Else Wh = Wh & ",'" & .List(I) & "'"
End If
Next
End With
If Wh <> "" Then
Chargement = "" & Format(Me.TextBox1, "yyyy-mm-dd hh:mm:ss") & ";" & Format(Me.TextBox2, "yyyy-mm-dd hh:mm:ss") & "; Where injonctions in (" & Wh & ")"
Else
Chargement = "" & Format(Me.TextBox1, "yyyy-mm-dd hh:mm:ss") & ";" & Format(Me.TextBox2, "yyyy-mm-dd hh:mm:ss") & ";"
End If
Unload Me
End Function
Private Sub CommandButton1_Click()
Debug.Print Me.CommandButton1.Caption = "Désélectionner tout"
Dim I As Integer
With Me.ListBox1
For I = 0 To .ListCount - 1
.Selected(I) = Me.CommandButton1.Caption = "Sélectionner tout"
Next
End With
If Me.CommandButton1.Caption = "Sélectionner tout" Then Me.CommandButton1.Caption = "Désélectionner tout" Else Me.CommandButton1.Caption = "Sélectionner tout"
End Sub
Private Sub CommandButton2_Click()
Dim Errs As String
If IsDate(Me.TextBox1) = False Then
Errs = "Date début: n'est pas au bon format jj/mm/aaaa hh:mm:ss ou pas résinée : " & vbCrLf & Me.TextBox1 & vbCrLf
End If
If IsDate(Me.TextBox2) = False Then
Errs = Errs & "Date Fin: n'est pas au bon format jj/mm/aaaa hh:mm:ss ou pas résinée : " & vbCrLf & Me.TextBox2 & vbCrLf
End If
If Errs <> "" Then MsgBox Errs: Exit Sub
Me.Hide
End Sub
Private Sub UserForm_Initialize()
Me.TextBox1 = ThisWorkbook.Sheets("Req_ExportUnionExcel").Range("B1")
Me.TextBox2 = ThisWorkbook.Sheets("Req_ExportUnionExcel").Range("B2")
Me.ListBox1.List = Array("0001", "0002", "0003", "0004", "0005", "0006", "0007", "0008", "0009", "0010")
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Cancel = Not CBool(CloseMode)
End Sub |
Partager