无法获取WorksheetFunction类的VLookup属性


0

我想在excel中实现条形码查找器,因此根据项目属于哪个组,我在单独的工作表中有项目名称和条形码。用户单击单选按钮(选择组1,组2或其他),列表框的填充范围设置为其中一个 我定义的动态名称范围

enter image description here

然后用户单击按钮以复制相应项目的条形码。这是与按钮关联的宏:

Sub Get_Barcode()
    Dim objData As New DataObject
    Dim barcode As String
    On Error GoTo Errorcatch
    barcode = Application.WorksheetFunction.VLookup(ListBox1.Text, ListBox1.ListFillRange, 1, False)
    objData.SetText barcode
    objData.PutInClipboard
    MsgBox "Barcode " & barcode & " copied to clipboard"
Errorcatch:
MsgBox Err.Description
End Sub

问题是它显示了一个 Unable to get the VLookup property of the WorksheetFunction class 我不知道我做错了什么

Answers:


1

解决了它。

更改了原始代码中的相应行,如下所示:

barcode = Application.VLookup(ListBox1.Text,ActiveWorkbook.Names(ListBox1.ListFillRange).RefersToRange,2,False)

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.