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
| Sub IdentifierCellulesAvecChaineDeCaractèresStipulée()
Dim SearchString, SearchChar, Texte_A_Afficher As String
Dim Texte_A_Afficher1, Texte_A_Afficher2, Texte_A_Afficher3 As String
Dim Feuille As Worksheet
Dim Cell As Range
Dim i As Long
' Pour chacune des feuilles contenues dans un classeur,
' cherche les cellules connant la chaîne de caractères SearchChar
' avec respect de la casse et applique une couleur de fond jaune
' si elle les contient.
SearchChar = "TC"
For Each Feuille In Worksheets
For Each Cell In Worksheets(Feuille.Name).UsedRange.Cells
UserForm1.Show False
Texte_A_Afficher1 = Cell.Address
UserForm1.Label1 = Texte_A_Afficher1
Texte_A_Afficher2 = Feuille.Name
UserForm1.Label2 = Texte_A_Afficher2
Texte_A_Afficher3 = Cell.Value
UserForm1.Label3 = Texte_A_Afficher3
' CreateObject("Wscript.shell").Popup Texte_A_Afficher, 0.1, "XXX", "X"
DoEvents
If Cell.HasFormula Then
SearchString = Cell.Formula
Texte_A_Afficher = Cell.Address & " // " & Feuille.Name & " // " & SearchString & " (dans le libellé !!!)"
UserForm1.Label4 = Texte_A_Afficher
DoEvents
If InStr(1, SearchString, SearchChar, 0) > 0 Then
Texte_A_Afficher = Feuille.Name & " // " & SearchString & " (dans le libellé !!!)"
' CreateObject("Wscript.shell").Popup Texte_A_Afficher, 1, "YYY"
Cell.Interior.ColorIndex = 7 'Rose fluo
End If
End If
If Not IsNumeric(Cell.Value) Then
SearchString = Cell.Value
Texte_A_Afficher = Cell.Address & " // " & Feuille.Name & " // " & SearchString & " (dans le libellé !!!)"
UserForm1.Label5 = Texte_A_Afficher
DoEvents
If InStr(1, SearchString, SearchChar, 0) > 0 Then
Texte_A_Afficher = Feuille.Name & " // " & SearchString & " (dans la formule !!!)"
' CreateObject("Wscript.shell").Popup Texte_A_Afficher, 1, "ZZZ"
Cell.Interior.ColorIndex = 6 'Jaune fluo
End If
End If
For i = 1 To 350000
Next i
UserForm1.Label1 = ""
UserForm1.Label2 = ""
UserForm1.Label3 = ""
UserForm1.Label4 = ""
UserForm1.Label5 = ""
Next Cell
Next Feuille
' Unload UserForm1
End Sub |
Partager