Private qui As Range, cellules_a_controler As Range, interdits Private Sub Worksheet_SelectionChange(ByVal Target As Range) If cellules_a_controler Is Nothing Then Set cellules_a_controler = Union(Range("A3"), Range("B5")) '====>> tes cellules a vérifier interdits = Array("", "/", ":", "*", "?", """", ">", "<", "|") End If If Not Intersect(Target, cellules_a_controler) Is Nothing Then Set qui = Target Else If Not qui Is Nothing Then Caractères qui Else Set qui = Nothing End If End If End Sub Private Sub Caractères(cellule As Range) Dim i As Integer, j As Integer, CarInc As String, CarInt As String, attention As Boolean For i = 1 To Len(cellule.Text) CarInc = Mid(cellule.Text, i, 1) For j = 0 To UBound(interdits) CarInt = interdits(j) If CarInc = CarInt Then attention = True With cellule.Characters(Start:=i, Length:=1).Font .FontStyle = "Gras" .ColorIndex = 3 .Size = 12 End With cellule.Activate End If Next j Next i If attention Then MsgBox "les caractères ici mis en rouge sont interdits !" End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question