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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
| Option Explicit
Dim v(10000, 6) As String
Dim nbV As Long
Private Sub CommandButton2_Click()
Me.Hide
End Sub
Private Sub ListView1_DblClick()
Dim indice As Long
indice = ListView1.SelectedItem.Tag
With ThisWorkbook.Sheets(v(indice, 0))
.Select
.Range("A" & CLng(v(indice, 6)) & ":M" & CLng(v(indice, 6))).Select
End With
End Sub
Private Sub TextBox1_Change()
AfficherVecteur
End Sub
Private Sub TextBox2_Change()
AfficherVecteur
End Sub
Private Sub TextBox3_Change()
AfficherVecteur
End Sub
Private Sub TextBox4_Change()
AfficherVecteur
End Sub
Private Sub TextBox5_Change()
AfficherVecteur
End Sub
Private Sub TextBox6_Change()
AfficherVecteur
End Sub
Private Sub UserForm_Initialize()
Dim f As Worksheet
Dim i As Long
Dim r As Range
nbV = -1
For Each f In ThisWorkbook.Worksheets
Set r = f.Range("A1")
If f.Name <> "Accueil" Then
For i = 2 To f.Range("A65536").End(xlUp).Row
nbV = nbV + 1
v(nbV, 0) = Trim(f.Name)
v(nbV, 1) = Trim(r.Offset(i - 1, 5))
v(nbV, 2) = Trim(r.Offset(i - 1, 0))
v(nbV, 3) = Trim(r.Offset(i - 1, 2))
v(nbV, 4) = Trim(r.Offset(i - 1, 3))
v(nbV, 5) = Trim(r.Offset(i - 1, 6))
v(nbV, 6) = i
Next i
End If
Next
AfficherVecteur
End Sub
Function AfficherVecteur()
ListView1.ListItems.Clear
Dim i As Long
For i = 0 To nbV
If Valide(i) Then AjoutListe i
Next i
End Function
Function Valide(i) As Boolean
Valide = ((v(i, 0) = TextBox1 Or TextBox1 = "") And _
(v(i, 1) = TextBox2 Or TextBox2 = "") And _
(v(i, 2) = TextBox3 Or TextBox3 = "") And _
(v(i, 3) = TextBox4 Or TextBox4 = "") And _
(v(i, 4) = TextBox5 Or TextBox5 = "") And _
(v(i, 5) = TextBox6 Or TextBox6 = ""))
End Function
Function AjoutListe(i)
Dim j As Long
With ListView1
.ListItems.Add , , v(i, 0)
For j = 1 To 5
.ListItems.Item(.ListItems.Count).ListSubItems.Add , , v(i, j)
Next j
.ListItems.Item(.ListItems.Count).Tag = i
End With
End Function |
Partager