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
| Private O As Worksheet 'déclare la variable O (Onglet)
Private TC As Variant 'déclare la variable TC (Tableau de Cellules)
Private NL As Integer 'déclare la variable NL (Nombre de Lignes)
Private NC As Integer 'déclare la variable NC (Nombre de Colonnes)
Dim f, choix(), Rng
Private Sub UserForm_Initialize()
Set f = Sheets("RECAPITULATIF")
Set Rng = f.Range("a3:s" & f.[a65000].End(xlUp).Row)
TblTmp = Rng.Value
For I = LBound(TblTmp) To UBound(TblTmp)
ReDim Preserve choix(1 To I)
For K = LBound(TblTmp) To UBound(TblTmp, 2)
choix(I) = choix(I) & TblTmp(I, K) & " * "
Next K
Next I
Me.ListBox1.List = choix
End Sub
Private Sub TextBox1_Change()
mots = Split(Trim(Me.TextBox1), " ")
Tbl = choix
For I = LBound(mots) To UBound(mots)
Tbl = Filter(Tbl, mots(I), True, vbTextCompare)
Next I
Me.ListBox1.List = Tbl
Me.Label1.Caption = UBound(Tbl) + 1
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As msforms.ReturnBoolean) 'au double-clic dans la ListBox1
Dim I As Integer 'déclare la variable I (Incrément)
Dim J As Integer 'déclare la variable J (Incrément)
Dim LeParcours As String
For I = 0 To Me.ListBox1.ListCount - 1 'Boucle 1 : sur toutes les lignes de la ListBox1
If Me.ListBox1.Selected(I) = True Then 'condition 1 : si la ligne est sélectionnée
For J = 2 To NL 'boucle 2 : sur toutes les lignes du tabelau TC
If TC(J, 2) = Me.ListBox1.Column(1, I) Then 'condition 2 : si les numéros de HYD sont égaux
O.Rows(J + 1).Select 'sélecionne la ligne J de l'onglet O
LeParcours = Me.ListBox1.Column(1, I)
Chemin = "C:/Users/nathan/dropbox1/HYD/HYD" & LeParcours & "\"
Application.DisplayFullScreen = False
ThisWorkbook.FollowHyperlink Chemin
Unload Me
'vide et ferme l'Usersorm
Exit Sub 'sort de la procédure
End If 'fin de la condition 2
Next J 'prochaine ligne de la boucle 2
End If 'fin de la condition 1
Next I 'prochaine ligne de la boucle 1
End Sub |
Partager