
Option Explicit
Sub colora()
Dim Tcelle As Range
Dim nRighe As Long, Ncol As Long
nRighe = Cells(Rows.Count, 1).End(xlUp).Row
Ncol = Cells(1, Columns.Count).End(xlToLeft).Column
Set Tcelle = Range(Cells(1, 1), Cells(nRighe, Ncol))
With Tcelle
.Interior.ColorIndex = xlNone
.Font.ColorIndex = 0
End With
For Each cella In Tcelle
If cella.Value = "ITALIA" Then
With cella
.Interior.ColorIndex = 3
.Font.ColorIndex = 6
End With
End If
Next
Set Tcelle = Nothing
End Sub
|
Option Explicit
Option Compare Text
Sub colora()
Dim Tcelle As Range
Dim nRighe As Long, Ncol As Long
nRighe = Cells(Rows.Count, 1).End(xlUp).Row
Ncol = Cells(1, Columns.Count).End(xlToLeft).Column
Set Tcelle = Range(Cells(1, 1), Cells(nRighe, Ncol))
With Tcelle
.Interior.ColorIndex = xlNone
.Font.ColorIndex = 0
End With
For Each cella In Tcelle
If instr(cella.Value, "ITALIA") > 0 Then
With cella
.Interior.ColorIndex = 3
.Font.ColorIndex = 6
End With
End If
Next
Set Tcelle = Nothing
End Sub |
Option Explicit
Sub colora()
Dim Tcelle As Range, cella As Variant
Set Tcelle = Range("A1:Z1000")
With Tcelle
.Interior.ColorIndex = xlNone
.Font.ColorIndex = 0
End With
For Each cella In Tcelle
If UCase(cella.Value) Like "*ITALIA*" Then
With cella
.Interior.ColorIndex = 3
.Font.ColorIndex = 6
End With
End If
Next
Set Tcelle = Nothing
End Sub |
