导致运行时错误的数组13类型不匹配

时间:2018-04-15 22:43:59

标签: excel excel-vba vba

我在行For i = LBound(buyArrayLow) To UBound(buyArrayLow)上收到运行时错误13,buyArrayLowbuyArrayHigh中有值。

Dim i As Long, j As Long, n As Long
Dim buyRngLow As Range
Dim buyRngHigh As Range
Dim buyArrayLow As Variant
Dim buyArrayHigh As Variant
Dim TempAr() As String

Set buyRngLow = Range("D" & lStartBuyRange)
Set buyRngHigh = Range("D" & lEndBuyRange)

buyArrayLow = buyRngLow.Value
buyArrayHigh = buyRngHigh.Value

For i = LBound(buyArrayLow) To UBound(buyArrayLow)
  For j = LBound(buyArrayHigh) To UBound(buyArrayHigh)
    If buyArrayLow(i, 1) = buyArrayHigh(j, 1) Then
      boolFound = True
      Exit For
    End If
  Next j

  If boolFound = False Then
    ReDim Preserve TempAr(n)
    TempAr(n) = buyArrayLow(i, 1)
    n = n + 1
  Else
    boolFound = False
  End If
Next i

0 个答案:

没有答案