Loop Vlookup - 执行代码时出错

时间:2016-12-09 17:36:24

标签: excel vba excel-vba

我有下面的代码,其中数据显示在工作表中的工作表中的工作表COT和查找值中。但是代码没有给我预期的回报,请你帮忙吗?

Dim aCell As Range
Dim S1 As Worksheet
Dim S2 As Worksheet
Dim W1 As Workbook


Set W1 = ThisWorkbook

Set S1 = W1.Sheets("COT")
Set S2 = W1.Sheets("Sheet1")

With S2

For Each aCell In .Range("A2:A" & LastRow)

.Cells(aCell.Row, 2) = Application.WorksheetFunction.VLookup(aCell.Value, S1.Range("A:D"), 2, 0)

Next
End With

0 个答案:

没有答案