VBA功能Offest

时间:2015-10-14 08:21:15

标签: excel vba excel-vba offset

我需要告诉我在for循环中看到的单元格左边的字符串5是否等于另一个单元格中的字符串(rString)。我无法让它发挥作用!

Function ColorFunction1(rColor As Range, rRange As Range, rString As Range, srRange As Range, Optional SUM As Boolean)
Dim rCell As Range
Dim lCol As Long
Dim lString As String
Dim sCell As Range
Dim offset As Integer
Dim vResult
offset = 4
lCol = rColor.Interior.ColorIndex
lString = rString.Value
Dim sString As String
If SUM = True Then
    For Each rCell In rRange
        If rCell.Interior.ColorIndex = lCol Then
        vResult = WorksheetFunction.SUM(rCell, vResult)
    End If
    Next rCell
Else
    For Each rCell In rRange
            If rCell.Interior.ColorIndex = lCol Then
                If StrComp(rCell.offset(0, -5).Value, lString) = 0 Then
                    vResult = 1 + vResult
                End If
            End If
    Next rCell

    End If
    ColorFunction1 = vResult
End Function

这是我的代码,任何人都可以帮忙吗?

0 个答案:

没有答案