excel - Application.Match 错误说类型不匹配
问题描述
我在用户窗体中使用一个组合框来显示来自某个单元格的值,我使用 application.match 来匹配要在其他文本框中显示的相应行
这是我的组合框代码:
Private Sub ComboBox1_Change()
If Me.ComboBox1.Value <> "" Then
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Student Profile")
Dim i As Integer
i = Application.Match(VBA.CLng(Me.ComboBox1.Value), sh.Range("A:A"), 0)
Me.TextBoxAddress.Value = sh.Range("D" & i).Value
Me.TextBoxContact.Value = sh.Range("E" & i).Value
Me.TextBoxName.Value = sh.Range("B" & i).Value
Me.TextBoxSection.Value = sh.Range("C" & i).Value '''
End If
错误说:
运行时错误 13:类型不匹配。
似乎是什么问题?
解决方案
请尝试此代码
i = Application.Match(VBA.CLng(Val(Me.ComboBox1.Value)), sh.Range("A:A"), 0)
推荐阅读
- rust - 混合选择!Rust 中的异步调用
- uml - 我应该在我的用例图中包含系统作为参与者吗?
- sql - SQL获取日期之间的行数
- r - 警告消息:要替换的项目数不是替换长度的倍数
- javascript - Javascript 引号索引器
- r - 拉取后如何在 R 中编辑 CSV 文件中的数据?
- google-chrome-extension - Node.js 导入/导出和 chrome/opera/firefox 扩展。2020年的情况
- php - StripeObject.php array_keys() 期望参数 1 为数组,给定 null
- c# - 使用 BotServiceStressToolkit 和 MockChannel 进行 BotFramework 负载测试。从 MockChannel 获取数据的问题
- python - 如何将 Python Flask 后端连接到 React 前端?它是如何协同工作的?