You need to enable JavaScript to run this app. VBA自定义MsgBox弹窗标题:替换默认Microsoft Excel为Contrôle
优惠活动
大模型
产品
解决方案
定价
更多

VBA自定义MsgBox弹窗标题:替换默认Microsoft Excel为Contrôle

VBA日期校验弹窗标题修改方案

最小改动实现

只需要给原有MsgBox语句补充标题参数即可,无需修改其他校验逻辑:
把原代码里的错误提示行:

MsgBox ("Entrez la date en format jj/mm/aaaa")

替换为:

MsgBox "Entrez la date en format jj/mm/aaaa", , "Contrôle"
  • 中间的参数留空表示沿用默认的「仅带确定按钮」的弹窗样式,最后一个参数就是自定义的弹窗标题

优化后稳定版本

原代码重复计算了Ma_date区域的相交判断,且批量修改多个单元格时会出现误报,可使用合并逻辑后的完整代码:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim intersectRange As Range
    Set intersectRange = Intersect(Target, Range("Ma_date"))
    
    ' 仅处理和Ma_date区域相交的修改
    If Not intersectRange Is Nothing Then
        ' 单单元格修改才触发校验,避免批量粘贴时逻辑异常
        If intersectRange.Count = 1 Then
            If VarType(intersectRange.Value) = vbDate Then
                Call CLICK_INFOS
            Else
                MsgBox "Entrez la date en format jj/mm/aaaa", vbOKOnly, "Contrôle"
            End If
        End If
    End If
End Sub

内容的提问来源于stack exchange,提问作者VBA_Anne_Marie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.26 19:45:03