Sub Italique()
Dim balise1$, balise2$, L1$, L2$, a$(), c As Range, n&, x$, sup%, i%, j%, k%, ss, s
balise1 = "<i>": balise2 = "</i>": L1 = Len(balise1): L2 = Len(balise2)
Application.ScreenUpdating = False
Cells.Font.Italic = False 'RAZ
With ActiveSheet.UsedRange 'la feuille active est traitée
'---tableau des bornes---
ReDim a(1 To .Count)
For Each c In .Cells
n = n + 1
x = CStr(c)
sup = 0
For i = 1 To Len(x)
If Mid(x, i, L1) = balise1 Then
j = InStr(i + L1, x, balise2)
k = InStr(i + L1, x, balise1)
If k = 0 Then k = 32767
If j And j <= k Then
sup = sup + L1
a(n) = a(n) & " " & i - sup + L1 & "," & j - i - L1
sup = sup + L2
i = j + L2 - 1
End If
End If
Next i, c
'---effacement des 2 balises---
.Replace balise1, "", xlPart
.Replace balise2, ""
'---application des formats---
n = 0
For Each c In .Cells
n = n + 1
If a(n) <> "" Then
ss = Split(a(n))
For i = 1 To UBound(ss)
s = Split(ss(i), ",")
c.Characters(s(0), s(1)).Font.Italic = True
Next i
End If
Next c
End With
End Sub
Sub Sansi()
mot = " subsp. "
For Each c In Range("B23:B200" & [B65000].End(xlUp).Row)
P = InStr(UCase(c), UCase(mot))
If P > 0 Then c.Characters(Start:=P, Length:=Len(mot)).Font.Italic = False
Next c
mot2 = " var. "
For Each c In Range("B23:B200" & [B65000].End(xlUp).Row)
P = InStr(UCase(c), UCase(mot2))
If P > 0 Then c.Characters(Start:=P, Length:=Len(mot2)).Font.Italic = False
Next c
mot3 = " sp. "
For Each c In Range("B23:B200" & [B65000].End(xlUp).Row)
P = InStr(UCase(c), UCase(mot3))
If P > 0 Then c.Characters(Start:=P, Length:=Len(mot3)).Font.Italic = False
Next c
End Sub
Sub Appel()
Call Italique
Call Sansi
End Sub
ou
Private Sub CommandButton1_Click()
Italique
Sansi
End Sub