Quelque chose comme cela va changer « test » dans toutes les cellules dans une gamme sélectionnée par l'utilisateur en gras. Il gère plusieurs occurrences dans une seule cellule
Le test est insensible à la casse
Option Explicit
Const strText As String = "test"
Sub ColSearch_DelRows()
Dim rng1 As Range
Dim rng2 As Range
Dim cel1 As Range
Dim cel2 As Range
Dim strFirstAddress As String
Dim lAppCalc As Long
Dim objRegex As Object
Dim RegMC As Object
Dim RegM As Object
Set objRegex = CreateObject("vbscript.regexp")
With objRegex
.Global = True
.Pattern = strText
End With
'Get working range from user
On Error Resume Next
Set rng1 = Application.InputBox("Please select range to search for " & strText, "User range selection", Selection.Address(0, 0), , , , , 8)
On Error GoTo 0
If rng1 Is Nothing Then Exit Sub
With Application
lAppCalc = .Calculation
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Set cel1 = rng1.Find(strText, , xlValues, xlPart, xlByRows, , False)
If Not cel1 Is Nothing Then
Set rng2 = cel1
strFirstAddress = cel1.Address
Do
Set cel1 = rng1.FindNext(cel1)
Set rng2 = Union(rng2, cel1)
Loop While strFirstAddress <> cel1.Address
End If
If Not rng2 Is Nothing Then
For Each cel2 In rng2
Set RegMC = objRegex.Execute(cel2.Value)
For Each RegM In RegMC
cel2.Characters(RegM.firstindex, RegM.Length + 1).Font.Bold = True
Next
Next
End If
With Application
.ScreenUpdating = True
.Calculation = lAppCalc
End With
End Sub
Combien de cellules sont là? Si pas beaucoup vous pouvez le faire manuellement en sélectionnant le mot spécifique dans la cellule et l'application de la mise en forme. Si vous avez plusieurs cellules, vous devrez utiliser vba. – assylias
de nombreuses cellules sont là ... ont également à faire pour beaucoup excelle ..... – user1271146
In vba, comment le faire .... – user1271146