Public Sub formatta() Dim Lista As Range Set Lista = Range(Cells(8, 11), Cells(8, 11).End(xlDown)) For Each cl In Lista If cl = "P" And cl.Offset(0, 1) <> "0" Or cl = "V" And cl.Offset(0, 1) <> "15b" Then cl.Interior.ColorIndex = 1 cl.Offset(0, 1).Interior.ColorIndex = 1 cl.Font.Color = vbWhite cl.Offset(0, 1).Font.Color = vbWhite ElseIf cl = "P" Then cl.Font.Color = vbRed Else cl.Font.Color = vbGreen End If Next End Sub
Public Sub formatta() Dim Lista As Range Set Lista = Range(Cells(8, 11), Cells(8, 11).End(xlDown)) For Each cl In Lista If cl = "P" And cl.Offset(0, 1) <> "0" Or cl = "V" And cl.Offset(0, 1) <> "15b" Then cl.Interior.ColorIndex = 1 cl.Offset(0, 1).Interior.ColorIndex = 1 cl.Font.Color = vbWhite cl.Offset(0, 1).Font.Color = vbWhite ElseIf cl = "P" Then cl.Font.Color = vbRed Else cl.Font.Color = vbGreen End If Next Call conta End Sub Sub conta() Set Lista = Range(Cells(8, 11), Cells(8, 11).End(xlDown)) somma = 0 For Each Cella In Lista If Cella.Interior.ColorIndex = 1 Then somma = somma + 1 End If Next MsgBox ("numero errori =" & somma) End Sub
Public Sub sostituisci() Dim Lista As Range Set Lista = Range(Cells(8, 11), Cells(8, 11).End(xlDown)) For Each cl In Lista If cl = "P" And cl.Offset(0, 1) <> "0" Or cl = "V" And cl.Offset(0, 1) <> "15b" Then cl.Interior.ColorIndex = 1 cl.Offset(0, 1).Interior.ColorIndex = 1 cl.Font.Color = vbWhite cl.Offset(0, 1).Font.Color = vbWhite ElseIf cl = "P" Then cl.Interior.ColorIndex = xlNone cl.Offset(0, 1).Interior.ColorIndex = xlNone cl.Font.Color = vbRed Else cl.Interior.ColorIndex = xlNone cl.Offset(0, 1).Interior.ColorIndex = xlNone cl.Font.Color = vbGreen End If Next Call conta End Sub Sub conta() Set Lista = Range(Cells(8, 11), Cells(8, 11).End(xlDown)) somma = 0 For Each Cella In Lista If Cella.Interior.ColorIndex = 1 Then somma = somma + 1 End If Next MsgBox ("numero errori =" & somma) End Sub