Option Explicit
Dim mesFrames As New CFrames
Private Sub C4_Change()
[COLOR="yellow"]dim aa as long[/COLOR]
Dim i&, fin&
If C4 = "" Then L1.ListItems.Clear: Label6.Caption = "": Exit Sub
fin = Feuil1.Range("A65536").End(xlUp).Row
aa = Feuil1.Range("A4:I" & fin)
For i = 1 To [COLOR="yellow"]UBound[/COLOR](aa)
For a = 1 To UBound(aa, 2)
If aa(i, a) Like "*" & C4 & "*" Then aa(i, 9) = "oui"
Next a
Next i
Y = 1
For i = 1 To UBound(aa)
If aa(i, 9) = "oui" Then Y = Y + 1
Next
If Y = 2 Then Label6.Caption = Y - 1 & " Ligne faisant référence à votre recherche a été trouvée "
If Y > 2 Then Label6.Caption = Y - 1 & " Lignes faisant référence à votre recherche ont été trouvées "
If Y < 2 Then L1.ListItems.Clear: Label6.Caption = "": GoTo 1
ReDim bb(Y - 1, 8)
Y = 1
For i = 1 To UBound(aa)
If aa(i, 9) = "oui" Then
For a = 1 To 8
bb(Y, a) = aa(i, a)
Next a
Y = Y + 1
End If
Next i
With L1
.ListItems.Clear
.View = lvwReport
.FullRowSelect = True
.Gridlines = True
For i = 1 To UBound(bb)
.ListItems.Add , , bb(i, 1)
For a = 2 To UBound(bb, 2)
.ListItems(.ListItems.Count).ListSubItems.Add , , bb(i, a)
Next a
Next i
1 End With
On Error Resume Next
With UserForm1
End Sub
Private Sub Frame1_Click()
End Sub
Private Sub UserForm_Initialize()
With L1
With .ColumnHeaders
.Clear
.Add , , "N° Dans amoire", 60
.Add , , "N° de Porte", 60
.Add , , "Cylindre", 60, 2
.Add , , "Type", 60, 2
.Add , , "Adresse", 300, 2
.Add , , "Coordonnée", 100, 2
.Add , , "Remarque", 180, 2
End With
.View = lvwReport
.FullRowSelect = False
End With
Dim c, n, ctrl: Set mesFrames.Parent = Me: Set mesFrames.Combo = C4
For Each ctrl In Me.Controls
c = UCase(Left(ctrl.Name, 1)): n = Right(ctrl.Name, Len(ctrl.Name) - 1)
If (c = "A" Or c = "D" Or c = "P") And IsNumeric(n) Then mesFrames.Add Me.Controls(ctrl.Name)
Next ctrl
End Sub