为什么两个函数结果不一致




Option Explicit
Sub Macro2()

    Dim i  As Integer
    For i = 5 To 219
        With ActiveSheet.Range("C" & CStr(i))
            .FormatConditions.Delete
            .FormatConditions.Add Type:=xlExpression, Formula1:="=AND(($C$" & CStr(i) & "=$E$" & CStr(i) & "),($E$" & CStr(i) & "=$F$" & CStr(i) & "),($F$" & CStr(i) & "=$G$" & CStr(i) & "))"
            .FormatConditions(1).Interior.ColorIndex = 15
        End With
        With ActiveSheet.Range("E" & CStr(i))
            .FormatConditions.Delete
            .FormatConditions.Add Type:=xlExpression, Formula1:="=AND(($C$" & CStr(i) & "=$E$" & CStr(i) & "),($E$" & CStr(i) & "=$F$" & CStr(i) & "),($F$" & CStr(i) & "=$G$" & CStr(i) & "))"
            .FormatConditions(1).Interior.ColorIndex = 15
        End With
        With ActiveSheet.Range("F" & CStr(i))
            .FormatConditions.Delete
            .FormatConditions.Add Type:=xlExpression, Formula1:="=AND(($C$" & CStr(i) & "=$E$" & CStr(i) & "),($E$" & CStr(i) & "=$F$" & CStr(i) & "),($F$" & CStr(i) & "=$G$" & CStr(i) & "))"
            .FormatConditions(1).Interior.ColorIndex = 15
        End With
        With ActiveSheet.Range("G" & CStr(i))
            .FormatConditions.Delete
            .FormatConditions.Add Type:=xlExpression, Formula1:="=AND(($C$" & CStr(i) & "=$E$" & CStr(i) & "),($E$" & CStr(i) & "=$F$" & CStr(i) & "),($F$" & CStr(i) & "=$G$" & CStr(i) & "))"
            .FormatConditions(1).Interior.ColorIndex = 15
        End With
    Next i
End Sub



Option Explicit
Sub Macro3()

    Dim i  As Integer
    For i = 5 To 219
        With ActiveSheet.Range("C" & CStr(i))
            .FormatConditions.Delete
            .FormatConditions.Add Type:=xlExpression, Formula1:="=AND((C" & CStr(i) & "=E" & CStr(i) & "),(E" & CStr(i) & "=F" & CStr(i) & "),(F" & CStr(i) & "=G" & CStr(i) & "))"
            .FormatConditions(1).Interior.ColorIndex = 15
        End With
        With ActiveSheet.Range("E" & CStr(i))
            .FormatConditions.Delete
            .FormatConditions.Add Type:=xlExpression, Formula1:="=AND((C" & CStr(i) & "=E" & CStr(i) & "),(E" & CStr(i) & "=F" & CStr(i) & "),(F" & CStr(i) & "=G" & CStr(i) & "))"
            .FormatConditions(1).Interior.ColorIndex = 15
        End With
        With ActiveSheet.Range("F" & CStr(i))
            .FormatConditions.Delete
            .FormatConditions.Add Type:=xlExpression, Formula1:="=AND((C" & CStr(i) & "=E" & CStr(i) & "),(E" & CStr(i) & "=F" & CStr(i) & "),(F" & CStr(i) & "=G" & CStr(i) & "))"
            .FormatConditions(1).Interior.ColorIndex = 15
        End With
        With ActiveSheet.Range("G" & CStr(i))
            .FormatConditions.Delete
            .FormatConditions.Add Type:=xlExpression, Formula1:="=AND((C" & CStr(i) & "=E" & CStr(i) & "),(E" & CStr(i) & "=F" & CStr(i) & "),(F" & CStr(i) & "=G" & CStr(i) & "))"
            .FormatConditions(1).Interior.ColorIndex = 15
        End With
    Next i
End Sub

posted @ 2010-05-26 19:37  dzqabc  阅读(286)  评论(0编辑  收藏  举报