欢迎光临散文网 会员登陆 & 注册

【实例11-判断单元格录入数据】Excel表格VBA编程实例 代码分享

2023-02-26 00:37 作者:凌霄百科_Excel办公程序  | 我要投稿


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

If Target.Column >= 3 And Target.Column <= 6 And Target.Value = "" Then

    Target.Value = "未考"

End If

End Sub


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column >= 3 And Target.Column <= 6 Then

    If IsNumeric(Target.Value) = True Then

        If Target.Value >= 0 And Target.Value <= 100 Then

            If Target.Value < 60 Then

            Target.Interior.ColorIndex = 3

            Else

            Target.Interior.ColorIndex = 0

            End If

        Else

            MsgBox "成绩范围是0~100!"

            Target.Value = ""

        End If

    Else

        If Target.Value <> "未考" Then

        MsgBox "文本只能输入“未考”!"

        Target.Value = ""

        End If

    End If

    If Target.Value = "" Then

    Target.Interior.ColorIndex = 0

    End If

End If

End Sub


【实例11-判断单元格录入数据】Excel表格VBA编程实例 代码分享的评论 (共 条)

分享到微博请遵守国家法律