为什么我在一个工作簿上收到类型不匹配错误,而在另一个工作簿上却没有?

问题描述 投票:0回答:0

首先,这是我的代码示例:

Private Sub PopoutLeadListBox_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim selectedItem As String
selectedItem = Me.PopoutLeadListBox.Column(61)

Set ws = ThisWorkbook.Sheets(Mark1.LEADLISTDROPDOWN.Value)


Mark1.WHYTEXTBOX.Value = Application.XLookup(Val(selectedItem), ws.Range("BI:BI"), ws.Range("CN:CN"))
End Sub
Private Sub PopoutLeadListBox_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim selectedItem As String
selectedItem = Me.PopoutLeadListBox.Column(11)

Set ws = ThisWorkbook.Sheets(SalesForm.BHSDLEADLISTSCOMBOBOXLF.Value)

SalesForm.BHSDTAPNAMELF.Value = Application.XLookup(Val(selectedItem), ws.Range("S:S"), ws.Range("T:T"))

第一个代码返回类型不匹配错误,但第二个代码则没有。据我所知,这两本工作簿的格式也相同。我是不是忽略了什么?

excel vba userform xlookup
© www.soinside.com 2019 - 2024. All rights reserved.