[英]Excel VBA Lookup table value based on combobox selection Causing Error
I have a userform that has comboboxes that lookup a value in a table to populate a textbox on the same userform. 我有一个带有组合框的用户窗体,该组合框在表中查找值以在同一用户窗体上填充文本框。 The code is working.
该代码正在运行。 It produces the desired results and the form data saves accurately to the table, however instead of getting my MsgBox "Saved", I get error 1004 'Unable to get the VLookup property of the worksheet function class.'
它会产生所需的结果,并且表单数据会准确地保存到表中,但是,我没有得到MsgBox“已保存”,而是得到了错误1004“无法获取工作表函数类的VLookup属性”。 When I debug the line highlighted is
Me.men10.Value = Application.WorksheetFunction.VLookup(rec1, rRange, 47, 0)
当我调试时突出显示的行是
Me.men10.Value = Application.WorksheetFunction.VLookup(rec1, rRange, 47, 0)
This is the sub procedure in it's entirety: 这是整个子过程:
Private Sub men8_Change()
Dim rec1 As String
Dim rRange As Range
Set rRange = Sheets("Recipe Box").Range("tblRecipes")
rec1 = Me.men8.Value
Me.men10.Value = Application.WorksheetFunction.VLookup(rec1, rRange, 47, 0)
End Sub
I have four of these on the form and as I said, everything works as it should but still results in the error. 我在表单上有四个,而且正如我所说,一切都可以正常进行,但仍然会导致错误。 Any suggestions?
有什么建议么? I have searched everywhere but can't find anything related to errors on working code.
我到处搜索,但找不到与工作代码错误相关的任何内容。
Here is a snippet of the form controls: The circled textbox (men10) is populated from the combobox (men8) above it. 这是表单控件的片段:带圆圈的文本框(men10)是从其上方的组合框(men8)填充的。
I was able to replicate this, the error occurs if: - 我能够复制它,如果发生以下错误:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.