Private Sub CommandButton1_Click()
Dim Ws As Worksheet, Cel As Range
Dim L1 As Long, L2 As Long
If ComboBox1.Value = "" Then Call MsgBox("Vous devez sélectionner une valeur", vbCritical, Application.Name)
If ComboBox1.ListIndex = -1 Then Exit Sub
Compte1 = 0: Compte2 = 0
For Each Ws In Worksheets
If Left(Ws.Name, 2) = "IO" Then
With Ws
For Each Cel In .Range("B2:B" & .Range("B65536").End(xlUp).Row)
If Cel.Value = ComboBox1.Value Or Cel.Offset(0, 2) = ComboBox1.Value Then
If Left(Ws.Name, 8) = "IO DELTA" Then Compte1 = Compte1 + 1
If Right(Ws.Name, 6) = "PROVOX" Then Compte2 = Compte2 + 1
End If
Next Cel
End With
End If
Next Ws
If Compte1 > 0 Then
ReDim Tbl1(1 To Compte1, 1 To 9)
For Each Ws In Worksheets
If Left(Ws.Name, 8) = "IO DELTA" Then
With Ws
For Each Cel In .Range("B2:B" & .Range("B65536").End(xlUp).Row)
If Cel = ComboBox1.Value Then
L1 = L1 + 1
Tbl1(L1, 1) = Cel
Tbl1(L1, 2) = Ws.Name
Tbl1(L1, 3) = Cel.Offset(0, -1)
Tbl1(L1, 4) = Cel.Offset(0, 1)
Tbl1(L1, 5) = Cel.Offset(0, 2)
Tbl1(L1, 6) = Cel.Offset(0, 3)
Tbl1(L1, 7) = Cel.Offset(0, 4)
Tbl1(L1, 8) = Cel.Offset(0, 5)
Tbl1(L1, 9) = Cel.Offset(0, 6)
End If
Next Cel
End With
End If
Next Ws
End If
If Compte2 > 0 Then
ReDim Tbl2(1 To Compte2, 1 To 6)
For Each Ws In Worksheets
If Right(Ws.Name, 6) = "PROVOX" Then
With Ws
For Each Cel In .Range("D2:D" & .Range("D65536").End(xlUp).Row)
If Cel = ComboBox1.Value Then
L2 = L2 + 1
Tbl2(L2, 1) = Cel
Tbl2(L2, 2) = Ws.Name
Tbl2(L2, 3) = Cel.Offset(0, -3)
Tbl2(L2, 4) = Cel.Offset(0, -2)
Tbl2(L2, 5) = Cel.Offset(0, -1)
Tbl2(L2, 6) = Cel.Offset(0, 1)
End If
Next Cel
End With
End If
Next Ws
End If
ComboBox1.ListIndex = -1
UsfListview.Show
End Sub