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
| Option Explicit
Option Compare Text
Const Sign As String = "RECHERCHES"
'ICI C'est la mise en place initialisation
Private Sub UserForm_Initialize()
'pour la date du jour
Me.Caption = Format(Date, "dddd dd mmmm yyyy")
With ListBox1
.ColumnCount = 7
.ColumnWidths = "150;100;0;80;80;70;0"
End With
Me.CommandButton1.Default = True
' pour définir la couleur des objets lors de l'initialisation d'un UserForm.
With RECHERCHETOUS
.BackColor = &H8000000F
.CommandButton1.BackColor = &H8000000F
.CommandButton2.BackColor = &H8000000F
.Label3.BackColor = &H8000000F
End With
End Sub
'ICI C'est le Moteur de Recherche
Private Sub CommandButton1_Click()
Dim F As Worksheet
Dim Plage As Range, C As Range
Dim T As String, Firstaddress As String
Dim x As Integer
ListBox1.Clear
T = Me.TextBox1
If T = "" Then Exit Sub
For Each F In Worksheets
With F
Set Plage = Application.Intersect(.UsedRange.Cells, .Range(.Cells(8, 1), .Cells(.Rows.Count, .Columns.Count)))
End With
Set C = Plage.Find(T, LookIn:=xlValues, LookAt:=xlPart)
If Not C Is Nothing Then
Firstaddress = C.Address
Do
With ListBox1
.AddItem F.Name
For x = 2 To 6
.List(.ListCount - 1, x - 1) = F.Cells(C.Row, x).Text
Next x
.List(.ListCount - 1, 6) = C.Address(False, False)
End With
Set C = Plage.FindNext(C)
Loop While Not C Is Nothing And C.Address <> Firstaddress
End If
Next F
If ListBox1.ListCount = 0 Then
MsgBox "Le Texte " & T & " n'a pas été trouvé" & vbLf & "Faites un essai sur une partie du nom", vbCritical, Sign
End If
End Sub
'ICI C'est la sélection au Double Click & Sortie du UserForm
Private Sub ListBox1_dblClick(ByVal Cancel As MSForms.ReturnBoolean)
With ListBox1
Application.Goto Sheets(.Text).Range(.List(.ListIndex, 6))
End With
Unload Me
End Sub
'ICI Sortie du UserForm
Private Sub CommandButton2_Click()
Unload Me
End Sub |
Partager