Private Sub CommandButton1_Click()
[COLOR="Red"][B]Dim DerLigEcr As Double[/B][/COLOR]
[COLOR="Blue"][B]Dim DerLigLec As Double[/B][/COLOR]
Sheets("Recherche").[H1].Value = TextBox1.Value
If TextBox1.Value = "" Then Exit Sub
Application.ScreenUpdating = False
x = 1
[COLOR="red"][B]DerLigEcr[/B][/COLOR] = Range("A65536").End(xlUp).Row
For Each WS In ThisWorkbook.Worksheets
With WS
If Left(.Name, 6) = "Encais" Then
[COLOR="SeaGreen"][B]' i = Len(TextBox1.Value)[/B][/COLOR]
[COLOR="blue"][B]DerLigLec[/B][/COLOR] = .Range("D65536").End(xlUp).Row
For Each Cellule In .Range("D2:D" & [COLOR="blue"][B]DerLigLec[/B][/COLOR])
[COLOR="seagreen"][B]' For j = 1 To 50
' If UCase(Mid(Cellule, j, i)) = UCase(TextBox1.Value) Then[/B][/COLOR]
If UCase(Cellule) Like UCase("*" & TextBox1.Value & "*") Then
trouve = True
[COLOR="red"][B]DerLigEcr[/B][/COLOR] = [COLOR="red"][B]DerLigEcr[/B][/COLOR] + 1
For col = 1 To 7
Cells([COLOR="red"][B]DerLigEcr[/B][/COLOR], col).Value = WS.Cells(Cellule.Row, col + 1).Value
Next
Total(1) = Total(1) + Cells([COLOR="red"][B]DerLigEcr[/B][/COLOR], 5).Value
Total(2) = Total(2) + Cells([COLOR="red"][B]DerLigEcr[/B][/COLOR], 6).Value
Total(3) = Total(3) + Cells([COLOR="red"][B]DerLigEcr[/B][/COLOR], 7).Value
x = x + 1
End If
[COLOR="seagreen"][B]' Next j[/B][/COLOR]
Next Cellule
End If
End With
Next WS
For col = 5 To 7
If Total(col - 4) <> 0 Then Cells([COLOR="red"][B]DerLigEcr[/B][/COLOR] + 2, col).Value = Total(col - 4)
Next
With Cells([COLOR="red"][B]DerLigEcr[/B][/COLOR] + 2, 3)
.Value = "Total "
.HorizontalAlignment = xlRight
.VerticalAlignment = xlCenter
End With
If trouve = False Then MsgBox "Pas de trace !"
Unload Me
Dim madate As String
madate = Format(Date, "dddd dd mmmm yyyy")
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "&""Verdana,Normal""&16Mot-clé : " & TextBox1
.RightHeader = ""
.LeftFooter = "&""Verdana,Normal""Encaissement 2008"
.CenterFooter = _
"&""Verdana,Normal""Edité le & " & madate & "&"" à ,Normal""& &""Verdana,Normal""à&"" à ,Normal"" &T"
.RightFooter = "&""Verdana,Normal""Page &P"
End With
Call Traitement
Application.ScreenUpdating = True
End Sub