功能标题自动突出显示错误(VBA)

时间:2019-03-09 03:28:58

标签: excel vba

After running my VBA code, the Function Header was suddenly highlighted. Anybody know why this might be happening and how I can fix this? Thanks! Click here to view a screenshot.

代码:

Function isDup(tweet1 As String, tweet2 As String, threshold As Double) As Boolean
    Dim sameWordCount As Integer
    Dim i As Integer
    Dim j As Integer
    Dim numOfWords As Integer

    sameWordCount = 0
    words1 = Split(tweet1)
    words2 = Split(tweet2)

    If (UBound(words1) - LBound(words1) + 1) >= (UBound(words2) - LBound(words2) + 1) Then
        numOfWords = UBound(words2) - LBound(words2) + 1
        For i = LBound(words2) To UBound(words2)
            Debug.Print "i: " & i & "/" & UBound(words2)
            For j = LBound(words1) To UBound(words1)
                Debug.Print "j: " & j & "/" & UBound(words1)
                If StrComp(words1(i), words2(j), vbTextCompare) = 0 Then
                    sameWordCount = sameWordCount + 1
                    Exit For
                End If
            Next j
        Next i
        If threshold * (UBound(words1) - LBound(words1) + 1) > sameWordCount Then
            isDup = False
        Else
            isDup = True
        End If
    Else
        numOfWords = UBound(words1) - LBound(words1) + 1
        For i = LBound(words1) To UBound(words1)
            For j = LBound(words2) To UBound(words2)
                If StrComp(words1(i), words2(j), vbTextCompare) = 0 Then
                    sameWordCount = sameWordCount + 1
                    Exit For
                End If
            Next j
        Next i
        If threshold * (UBound(words2) - LBound(words2) + 1) > sameWordCount Then
            isDup = False
        Else
            isDup = True
        End If
    End If

    Debug.Print sameWordCount & "/" & numOfWords & " words the same"

0 个答案:

没有答案