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
| Option Explicit
Private Sub ListBox1_Click() 'OK
With Me.ListBox1
AfficheTextBox .ListIndex + 2 ' N° d'index + 2 parce-que le premier élément est 0 et la ligne des données commence à 2
End With
End Sub
Private Sub AfficheTextBox(Ligne) 'OK
Dim c As Byte, d As Byte, e As Byte, f As Byte, lignebd As Long
lignebd = ListBox1.List(Ligne - 2, 0)
For c = 2 To 4
' Place dans TextBox + c la valeur de la colonne C + 1 (a partir de la colonne ) de la ligne définie par l'argument ligne
Me.Controls("TextBox1") = Sheets("Recap").Cells(lignebd, 1)
Me.Controls("TextBox" & c) = Sheets("Recap").Cells(lignebd, c + 1)
Me.Controls("TextBox5") = Sheets("Recap").Cells(lignebd, c + 9)
Next c
For d = 6 To 19
Me.Controls("TextBox" & d) = Sheets("Recap").Cells(lignebd, d + 6)
Next d
For e = 20 To 21
Me.Controls("TextBox" & e) = Sheets("Recap").Cells(lignebd, e + 6)
Next e
For f = 1 To 3
Me.Controls("ComboBox" & f) = Sheets("Recap").Cells(lignebd, f + 5)
Next f
End Sub
Private Sub NouvelleRecherche_Click() 'OK
SRecherche.TextBox1 = ""
Unload Me
SRecherche.Show
End Sub
Private Sub UserForm_initialize() 'OK
Dim cell As Range, myRange As Range
Dim x As Long
ListBox1.Clear
Me.ListBox1.ColumnCount = 2
Me.ListBox1.ColumnWidths = "0;140"
Sheets("Recap").Activate
x = Range("A65536").End(xlUp).Row
Set myRange = Sheets("Recap").Range("AA2" & ":" & "AA" & x)
For Each cell In myRange
With Me.ListBox1
If Format(cell.Value, "mm/yyyy") = SRecherche.TextBox1.Value Then
ListBox1.AddItem cell.Row
ListBox1.List(ListBox1.ListCount - 1, 1) = Range("M" & cell.Row)
End If
End With
Next
End Sub |
Partager