Grazie!!
Moderatori: Anthony47, Flash30005
Private Sub Worksheet_Change(ByVal Target As Range)
' QUI va scritto il codice
End Sub
Option Explicit
Option Compare Text
Private Sub Worksheet_Change(ByVal Target As Range)
Dim I As Integer, Val1 As String, Val2 As String
If Intersect(Target, Range("B2:B10")) Is Nothing Then ' <<===== qui scrivi iltuo intervallo
Exit Sub
End If
Val1 = Range("C1") ' <<==== qui c'è la prima parola
Val2 = Range("D1") ' <<==== qui c'è la seconda parola
With Target.Characters(Start:=1, Length:=Len(Target)).Font
.FontStyle = "Normale"
.ColorIndex = xlAutomatic
End With
For I = 1 To Len(Target)
If Mid(Target, I, Len(Val1)) = Val1 Then
With Target.Characters(Start:=I, Length:=Len(Val1)).Font
.FontStyle = "Grassetto"
.ColorIndex = 3
End With
End If
If Mid(Target, I, Len(Val2)) = Val2 Then
With Target.Characters(Start:=I, Length:=Len(Val2)).Font
.FontStyle = "Grassetto"
.ColorIndex = 5
End With
Exit For
End If
Next I
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myArea As String, myWords, myBold, myColors, myUnderl, mySize, myTarget
Dim myF, I As Long
'
myArea = "B1:B100" '<<< L' area in cui sara' effettuata la ricerca
'
If Application.Intersect(Target, Range(myArea)) Is Nothing Then Exit Sub
If Target.Count <> 1 Then Exit Sub
If IsError(Target.Value) Then Exit Sub
'
myTarget = Replace(Replace(Replace(Target.Value, ",", " "), ".", " "), "?", " ") & " "
Application.EnableEvents = False
'il mio dizionario di Parole, Grassetto, Sottolineato, Colore
myWords = Array("Rimpatriato", "Dimesso", "terza")
myBold = Array(1, 0, 1) '1=Si, 0=No
myUnderl = Array(0, 1, 0) 'idem
mySize = Array(0, 14, 0) '0=default, >0=imposta
myColors = Array(RGB(255, 0, 0), RGB(0, 255, 0), RGB(255, 255, 0))
'
'Ripristina formati:
Target.Font.FontStyle = "Normale" '<*
Target.Font.ColorIndex = xlAutomatic '<*
Target.Font.Underline = xlUnderlineStyleNone '<*
Target.Font.Size = Application.StandardFontSize '<*
'
'Ricerca e modifica:
For I = LBound(myWords, 1) To UBound(myWords, 1)
myF = InStr(1, myTarget, (myWords(I) & " "), vbTextCompare)
If myF > 0 Then
With Target.Characters(Start:=myF, Length:=Len(myWords(I))).Font
.Bold = myBold(I)
.Color = myColors(I)
If myUnderl(I) = 0 Then .Underline = xlUnderlineStyleNone Else .Underline = xlUnderlineStyleSingle
If mySize(I) > 0 Then .Size = mySize(I)
End With
End If
Next I
'
Application.EnableEvents = True
End Sub

Torna a Applicazioni Office Windows
| Mantenere la stessa formattazione con Errore Autore: danibi60 |
Forum: Applicazioni Office Windows Risposte: 5 |
| Problema con copia dati senza formattazione Autore: systemcrack |
Forum: Applicazioni Office Windows Risposte: 9 |
Visitano il forum: Nessuno e 15 ospiti