应用程序匹配错误指出类型不匹配



我在用户窗体中使用了一个显示某个单元格值的组合框,我使用 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)

最新更新