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
|
Private Sub CommandButton2_Click()
Dim Cel As Range
Dim I As Long
ListBox1.Clear
For Each Cel In Plage.Columns(4).Cells 'recherche seulement sur la dernière colonne de la plage
If Cel.Value = TextBox1.Text Then
ListBox1.AddItem Cel.Offset(, -3).Value
ListBox1.Column(1, I) = Cel.Offset(, -2).Value
ListBox1.Column(2, I) = Cel.Offset(, -1).Value
ListBox1.Column(3, I) = Cel.Value
ListBox1.Column(4, I) = Cel.Row
I = I + 1
End If
Next Cel
End Sub
Private Sub ListBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim I As Long
Plage.Font.Bold = False
For I = 0 To ListBox1.ListCount - 1
Plage.Rows(ListBox1.Column(4, I) - 1).Font.Bold = ListBox1.Selected(I)
Next I
End Sub
Private Sub UserForm_Activate()
Dim I As Long, Large
With Worksheets("Essai"): Set Plage = .Range(.Cells(2, 1), .Cells(.Rows.Count, 4).End(xlUp)): End With
For I = 1 To Plage.Columns.Count: Large = Large & Round(Plage.Columns(I).Width) & "pt;": Next
Large = Large & "0pt" 'rajoute une dimension égale à 0 pour la cacher, cette colonne contient les numéros de ligne
With ListBox1
.ColumnCount = Plage.Columns.Count + 1
.ColumnWidths = Large
.ListStyle = 1
.MultiSelect = 1 'ne permet pas la gestion de l'événement Click() sur la ListBox !
End With
End Sub |
Partager