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
| Sub RechercherNoms()
Dim Sh As Worksheet, c As Range, Nom As String, firstAddress As String, col1, col2
Nom = InputBox("Nom à chercher dans toutes les feuilles", "Rechercher")
If Nom <> "" Then
For Each Sh In ThisWorkbook.Worksheets
Select Case Sh.Name
Case "TOTO"
col2 = 3
Case "LOGICIELS - LICENCES"
col2 = 4
'je supose que le END IF En trop etait pour le cas ou le nom du sheets etait diférent des deux premiers précédement cité!!!!?
'donc on rajoute un CASE ELSE
Case Else
col2 = 5
End Select
With Sh
.Activate ' je te met activate ici pour que tu puisse voir le travail se faire mais c'est pas utilse
Set c = .Range(.Cells(1, 1), .Cells(Rows.Count, col2)).Find(Nom, LookIn:=xlValues, LookAt:=xlPart)
If Not c Is Nothing Then
firstAddress = c.Address
Do
.Range(.Cells(c.Row, 1), .Cells(c.Row, col2)).Interior.ColorIndex = 38
c.Select ' je te met le select ici pour que tu puisse voir le sheets se colorer au fur et a mesure mais c'est pas utile car les select et activate ralentissent la macro
strreponse = MsgBox(Sh.Name & "!" & c.Address & vbCrLf & _
"Oui pour continuer la recherche" & vbLf & _
"Non pour sortir", vbYesNo)
If strreponse = vbNo Then Exit Sub
Set c = .Range(.Cells(1, 1), .Cells(Rows.Count, col2)).FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
Set c = Nothing
End If
End With
Next Sh
End If
End Sub |
Partager