两张表之间的Vlookup - 从源表到目标的文本查找无法获取结果

时间:2017-06-27 18:27:53

标签: excel excel-vba vlookup vba

        Dim rw as long
        Dim lookupvalue as string
        Dim targetlookupvalue as variant
        Dim wbthis as workbook
        Dim countrywbrange as range

        With wbThis.ActiveSheet

             For rw = 2 To Cells(Rows.Count, 1).End(xlUp).Row
                lookupvalue = Cells(rw, 5)
                On Error Resume Next

                     Cells(rw, 3) = Application.WorksheetFunction.VLookup(lookupvalue, countrywbrange, 4, False)
                      countrywbrange.Select
                      MsgBox lookupvalue & Cells(rw, 3)

                      targetlookupvalue = Cells(rw, 3)

                     If (IsEmpty(targetlookupvalue)) Then
                    MsgBox "WIP targetvalue is empty"


                    Else
                    MsgBox "proceed"

                End If

            Next rw

          End With

我正在尝试引用国家/地区代码从其他工作表中获取国家/地区,但变量变量始终返回空。 Lookupvalue返回要获取的值,我无法理解错误是什么。请求专家为您提供帮助。

0 个答案:

没有答案