【问题标题】:Type mismatch, conflicting macros类型不匹配,宏冲突
【发布时间】:2021-04-30 19:51:38
【问题描述】:

我的第一个 VBA 脚本运行良好,

Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Application.Intersect(Target, Range("C9:G9,C15:G15,C21:G21,C27,G27")) _
  Is Nothing) Then
    With Target
        If Not .HasFormula Then
            Application.EnableEvents = False
            .Value = UCase(.Value)
            Application.EnableEvents = True
        End If
    End With
End If
End Sub

这使得在单元格中输入的所有文本在用户输入后都大写

然后我有一个宏按钮来清除某些单元格

Sub inputcaps()
Range("C9", "G9").Value = ""
End Sub

按下此宏后它工作正常,但我确实收到“运行时错误'13':类型不匹配”错误,第一个脚本停止工作,我必须重新启动 Excel 工作表。

我该如何解决这个问题??

调试将我带到第一个脚本中的 .Value = UCase(.Value)

谢谢

【问题讨论】:

    标签: excel vba type-mismatch


    【解决方案1】:

    您需要按照以下代码进行操作:-

    简单代码中没有更多问题首先 EnableEvents = false 并在完成三月之前写入 EnableEvents = true

    喜欢这个代码:

     Sub inputcaps()
       Application.EnableEvents = False
    
        Range("C9", "G9").Value = ""
    
       Application.EnableEvents = True
    
    End Sub
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 2018-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多