VBA VLookup不返回任何结果,但我可以直接调用这些值

时间:2018-09-17 16:48:08

标签: excel vba formula vlookup

我不确定此VBA VLookup在这里发生了什么。

我可以直接从单元格中调用该值。我可以调用其他工作簿定义的范围内的任何单元格值。但是,当我尝试将其应用于Application Vlookup时,它什么也没做。...

Set report_ws = report_wb.Worksheets(1)
Set report_rng = report_ws.Range("B2:B" & last_row)
' last_row has been verify with Debug.Print

With inv_twcl_ws
    x = Trim(inv_twcl_ws.Cells(2, 1).Value)
    ' x has been verify with Debug.Print
    inv_twcl_ws.Cells(2, 7).Value = .Application.WorksheetFunction.VLookup(x, report_rng, 1, False)
    '.Cells(2, 7).Value = report_rng.Cells(2, 1) This works so why not the vlookup!!!
End With

我也尝试过:

inv_twcl_ws.Cells(2, 7).Formula = .Application.WorksheetFunction.VLookup(x, report_rng, 1, False)

根据评论,我尝试了以下操作,但仍然没有运气:

.Cells(2, 7).Formula = Application.WorksheetFunction.VLookup(x, report_rng, 1, False)

并且:

inv_twcl_ws.Cells(2, 7).Formula = Application.WorksheetFunction.VLookup(x, report_rng, 1, False)

如果没有发现任何东西,我也曾尝试使用IfError到达那里。

.Cells(2, 7).Formula = Application.WorksheetFunction.IfError(Application.WorksheetFunction.VLookup(x, report_rng, "Yes", True), "No")

0 个答案:

没有答案