Option Compare Text 'la casse est ignorée
Private Sub Worksheet_Activate()
Dim critere As Range, crit1$, L%, crit2$, lig&, i&, c As Range, p%
Application.ScreenUpdating = False
Columns(1).Clear 'RAZ
For Each critere In Sheets("mots recherchés").[A1].CurrentRegion.Offset(1)
crit1 = Trim(critere)
If crit1 <> "" Then
L = Len(crit1)
crit2 = "*" & crit1 & "*"
lig = lig + 1
With Cells(lig, 1)
.Font.Bold = True 'gras
.Font.Color = vbBlue 'bleu
.Font.Size = 14 'taille
.Value = crit1
End With
lig = lig + 1
With Sheets("texte de base").[A1].CurrentRegion
For i = 2 To .Rows.Count Step 2
If Application.CountIf(.Cells(i, 1).Resize(2), crit2) Then
Cells(lig, 1).Resize(2) = .Cells(i, 1).Resize(2).Value 'copie les valeurs
For Each c In Cells(lig, 1).Resize(2)
Do
p = InStr(p + 1, c, crit1)
If p Then
With c.Characters(p, L)
.Font.Bold = True 'gras
.Font.Size = 14 'taille
End With
Else
Exit Do 'sort de la boucle
End If
Loop
Next c
lig = lig + 2
End If
Next i
End With
End If
Next critere
End Sub