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
| Private Sub CmbRecherche_Click()
Dim Cell As Range
Dim Tab1(0 To 50, 0 To 5) As String
Dim I As Byte
Dim L As Byte
If CmbLigne.Value = "" And CmbNat.Value = "" Then
MsgBox "Veuillez choisir une ligne de crédit ou la nature", vbInformation + vbOKOnly, "Avertissement..."
LstResult.Clear
Exit Sub
End If
If CmbLigne.Value <> "" Then
L = Len(CmbLigne)
For Each Cell In Sheets("Crédit").Range("IntituCred")
If UCase(Left(Cell.Text, L)) = UCase(CmbLigne.Text) Then
Tab1(I, 0) = Cell.Text
Tab1(I, 1) = Cell.Offset(0, 1).Text
Tab1(I, 2) = Cell.Offset(0, 2).Text
Tab1(I, 3) = Cell.Offset(0, 3).Text
Tab1(I, 4) = Cell.Offset(0, 4).Text
I = I + 1
End If
LstResult.ColumnCount = 5
LstResult.ColumnWidths = "2cm" & ";" & "7cm" & ";" & "3cm" & ";" & "3cm" & ";" & "3cm"
LstResult.List = Tab1()
Next
ElseIf CmbNat.Value <> "" Then
L = Len(CmbNat)
For Each Cell In Sheets("Crédit").Range("IntituNat")
If UCase(Left(Cell.Text, L)) = UCase(CmbNat.Text) Then
Tab1(I, 0) = Cell.Offset(0, -2).Text
Tab1(I, 1) = Cell.Offset(0, -1).Text
Tab1(I, 2) = Cell.Text
Tab1(I, 3) = Cell.Offset(0, 1).Text
Tab1(I, 4) = Cell.Offset(0, 2).Text
I = I + 1
End If
Next
LstResult.ColumnCount = 5
LstResult.ColumnWidths = "2cm" & ";" & "7cm" & ";" & "3cm" & ";" & "3cm" & ";" & "3cm"
LstResult.List = Tab1()
End If
End Sub |
Partager