我在 Excel 2010 VBA 中使用 vlookup 时遇到问题
我想遍历空白列中的每个单元格,并从数据源的相邻列中查找一个值。我想循环执行此操作。我看过很多论坛,可以让它正常工作。
这是我的代码示例
Sheets("NPT(hrs)").Activate
Dim NumberRows As Integer
NumberRows = Range("a:a").Find("*", Range("A1"), SearchDirection:=xlPrevious).Row
NumberRows = NumberRows
ActiveCell.Offset(2, 69).Activate
For RowNum = 1 To NumberRows
If Len(Range("BQ1").Offset(RowNum, 0)) = 0 Then
ActiveCell.Value = Application.WorksheetFunction.VLookup(Cells(RowNum, 68), "Equipment!A:K", 7, False)
ActiveCell.Offset(1, 0).Activate
'' This approach never workedXXX
'v = WorksheetFunction.VLookup(Cells(RowNum, 68), "Equipment!A:K", 7, False)
' ActiveSheet.Cells(RowNum , 69).Formula = "=VLOOKUP(Cells(RowNum,68) ,Equipment!A:K,7,false)"
'ActiveCell.Text = "v"
'MsgBox "fin work?"
End If