excel 单击单元格后单元里的值自动加1

来源:互联网 发布:windows10笔记本优化 编辑:程序博客网 时间:2024/05/02 03:10

打开excel  文件  按下ALT+F11快捷键打开Microsoft visual Basic 以话框,单击ThisWorkbook,然后填入以后语句保存即可

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)


        If Target.Address = "$B$1" Then    单击B1
           Target.Value = Target.Value + 1
        End If
         If Target.Address = "$B$2" Then      ’单击B2
            Target.Value = Target.Value + 1
        End If
         If Target.Address = "$B$3" Then
           Target.Value = Target.Value + 1
        End If
        If Target.Address = "$B$4" Then
           Target.Value = Target.Value + 1
        End If
End Sub



原创粉丝点击