比较数组时使用连接函数 - 运行时错误91

时间:2014-08-11 17:24:11

标签: vba excel-vba excel

我遇到连接功能问题,除了我在连接功能下得到错误91之外,其他一切都有效。我试图比较两个数组,看它们是否相等......

我在一组范围内检查一个字符串(guess参数),以查看guess-argument(国家名称)是否在行集上可用。

任何人都知道问题可能是什么?

Private Function perform_word(guess As String)

Dim area As Range
Dim hold_split() As String
Dim check_sum As String
Dim check_word As String
Dim rng As String
Dim fng() As String

Set area = Range("A1:G7")

ReDim hold_split(1 To Len(guess))

For i = 1 To Len(guess)
    hold_split(i) = Mid(guess, i, 1)
Next i

For i = 1 To area.Rows.Count
    For j = 1 To area.Columns.Count
    rng = area(i, j).Value
    area(i, j).Select
    If rng = hold_split(1) Then
    Dim end_game() As Variant
        ReDim end_game(1 To Len(guess))
        For k = 1 To Len(guess)

            end_game(k) = Cells(i, j).Offset(0, k - 1)
            Debug.Print end_game(k)
            Next k
        If Join(hold_split, Nothing) = Join(end_game, Nothing) Then  <<--- error 91 here! :(


        End If
    End If
    Next j
Next i

If check_sum = guess Then
    Debug.Print check_sum
End If
perform_word = hold_split
End Function

0 个答案:

没有答案