Private Sub GetLine()
On Error Resume Next
If ListBox1.ListCount > 0 Then
LigneSelect = ListBox1.Column(1)
If Err <> 0 Then Exit Sub
Call RowSelection
Unload Me
End If
End Sub
Private Sub CommandButton1_Click()
Call GetLine
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Call GetLine
End Sub
Private Sub TextBox1_Change()
Dim S As Worksheet
Dim R As Range
Dim var
Dim i&
Dim j&
Dim A$
Dim B$
Dim T()
On Error GoTo Erreur
Set S = Sheets(NOM_FEUILLE)
Set R = S.Range("a1:a" & S.[a65536].End(xlUp).Row & "")
var = R
A$ = LCase(TextBox1.Text)
For i& = 2 To UBound(var, 1)
B$ = LCase(Trim(var(i&, 1)))
If Mid(B$, 1, Len(A$)) = A$ Then
j& = j& + 1
ReDim Preserve T(1 To 2, 1 To j&)
T(1, j&) = var(i&, 1)
T(2, j&) = i&
End If
Next i&
If j& = 0 Then
ListBox1.Clear
TextBox1.Text = Mid(TextBox1.Text, 1, Len(TextBox1.Text) - 1)
Exit Sub
End If
If j& > 1 Then
ListBox1.List = Application.WorksheetFunction.Transpose(T)
ElseIf j& = 1 Then
ListBox1.Column = T
End If
Exit Sub
Erreur:
Select Case Err
Case 9
MsgBox "La feuille ''" & NOM_FEUILLE & "'' est introuvable."
Case Else
MsgBox "Erreur : " & Err.Number & vbCrLf & Err.Description
End Select
End Sub
Private Sub UserForm_Initialize()
With Me
.Caption = "Recherche (accès rapide)"
.CommandButton1.Caption = "Fiche du produit"
.CommandButton2.Caption = "Quitter"
.ListBox1.ColumnCount = 2
.ListBox1.ColumnWidths = "50;0"
End With
End Sub