Format date dans tableau VBA
p
Bonjour, j'ai un code qui permet de selectionner une plage de celulle en fonction de certain critères, sans ces plage il y a des dates et lors de la transition elle changent de format et inverse le mois et le jour. Voici le code :
Option Explicit
Dim f As Worksheet, fs As Worksheet, tablo, tabloR(), dico As Object, k, kp
Dim i&, j&, t&
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
If ComboBox1.ListIndex = -1 Or TextBox1 = "" Or TextBox2 = "" Then
MsgBox "Saisie incomplète.", 16
Range("A2").Select
Exit Sub
End If
t = 0
For i = 1 To UBound(tablo, 1)
If tablo(i, 6) = ComboBox1 And tablo(i, 23) >= Val(TextBox1) _
And tablo(i, 23) <= Val(TextBox2) And tablo(i, 2) = "OK" And tablo(i, 35) = "" And tablo(i, 55) = 0 Then
ReDim Preserve tabloR(1 To 23, 1 To t + 1)
For j = 1 To 23
tabloR(j, 1 + t) = tablo(i, j + 10)
Next j
t = t + 1
End If
Next i
fs.Range("K4").CurrentRegion.Offset(1, 0).ClearContents
fs.Range("B2") = ComboBox1
fs.Range("F1") = TextBox1
fs.Range("F2") = TextBox2
Range("A2").Select
On Error Resume Next
fs.Range("A5").Resize(UBound(tabloR, 2), 22) = Application.Transpose(tabloR)
fs.Range("A5:T" & fs.Range("A" & Rows.Count).End(xlUp).Row).Select
If Err.Number > 0 Then
MsgBox "Aucune valeur pour ce transporteur.", 16
Range("A2").Select
End If
'Call trinb
'Call selectall
Selection.Copy
'Call testmail
Unload Me
End Sub
Private Sub UserForm_initialize()
Set f = Sheets("ANALYSE LIV")
Set fs = Sheets("Selection")
TextBox1 = 0
TextBox2 = 12
tablo = f.Range("A3:BC10000")
Set dico = CreateObject("Scripting.Dictionary")
'On crée le dico
For i = 1 To UBound(tablo, 1)
dico(tablo(i, 6)) = UCase(tablo(i, 6))
Next i
k = dico.keys
'On classe les éléments du dico
For i = 0 To dico.Count - 1
For j = 0 To dico.Count - 1
If k(i) < k(j) Then
kp = k(i)
k(i) = k(j)
k(j) = kp
End If
Next j
Next i
'On efface et on reconstitue le dico
dico.RemoveAll
For i = 0 To UBound(k, 1)
dico(k(i)) = ""
Next i
On Error Resume Next
ComboBox1.List = Application.Transpose(dico.keys)
If Err.Number > 0 Then
MsgBox "Ancun transporteur ne correspond aux criètères.", 16
End If
End Sub
Bonjour,
Et sans fichier on fait comment pour savoir quelles textebox ou combobox doivent contenir une date
p
Les dates sont dans une cellule récupéré sur une feuille. Je fabrique un fichier et je le dépose.
p
C'est trop compliqué de faire un fichier sans données sensible.
Je reformule ma question : Comment faire en sorte dans ce code :
For i = 1 To UBound(tablo, 1)
If tablo(i, 6) = ComboBox1 And tablo(i, 23) >= Val(TextBox1) _
And tablo(i, 23) <= Val(TextBox2) And tablo(i, 2) = "OK" And tablo(i, 35) = "" And tablo(i, 55) = 0 Then
ReDim Preserve tabloR(1 To 23, 1 To t + 1)
For j = 1 To 23
tabloR(j, 1 + t) = tablo(i, j + 10)
Next j
t = t + 1
End If
Next i
Les dates choisie soit au bon format ?