我努力理解为什么这不起作用......代码没有崩溃但是在Watch窗口中VLookUpsStorer
的每个值都是"错误2042&#34 ;.
有人可以帮我发现错误吗?
Dim I As Long
Dim VLookUpsStorer As Variant
ReDim VLookUpsStorer(1 To Range("A" & Rows.Count).End(xlUp).Row - 1, 1 To 3) As Variant
Dim TotalRows As Integer
TotalRows = Sheets("Sheet1").Range("D" & Rows.Count).End(xlUp).Row
Worksheets("Sheet2").Activate
With Sheets("Sheet1")
For I = 2 To Range("A" & Rows.Count).End(xlUp).Row
If Worksheets("Sheet2").Range("A" & I) <> "" Then
VLookUpsStorer(I - 1, 1) = Application.VLookup(Worksheets("Sheet2").Range("A" & I), .Range("C2:D" & TotalRows), 2, False)
VLookUpsStorer(I - 1, 2) = Application.VLookup(Worksheets("Sheet2").Range("A" & I), .Range("C2:E" & TotalRows), 3, False
VLookUpsStorer(I - 1, 3) = Application.VLookup(Worksheets("Sheet2").Range("A" & I), .Range("C2:F" & TotalRows), 4, False)
Else
Exit For
End If
Next I
End With
Range(Cells(2, 7), Cells(Range("A" & Rows.Count).End(xlUp).Row, 9)) = VLookUpsStorer
编辑2:2张样子的样本(在我将它们放入相同的通用格式之前(但没有差异))