【问题标题】:Application.Match error says type mismatchApplication.Match 错误说类型不匹配
【发布时间】:2020-04-01 19:25:20
【问题描述】:

我在用户窗体中使用组合框来显示来自某个单元格的值,我使用 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:类型不匹配。

似乎是什么问题?

【问题讨论】:

    标签: excel vba


    【解决方案1】:

    请试试这个代码

    i = Application.Match(VBA.CLng(Val(Me.ComboBox1.Value)), sh.Range("A:A"), 0)
    

    【讨论】:

      猜你喜欢
      • 2014-11-02
      • 2022-01-13
      • 2013-01-16
      • 2014-02-05
      • 2018-06-08
      相关资源
      最近更新 更多