1. 顽石财经首页
  2. 专题归档

VBA判断某列数据是否发生变化

'放置位置:Sheet
Dim s
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Target.Column <> 1 Or Target.Row < 2 Then Exit Sub
    Dim ns
    ns = Target.Value
    If s = "" Then
        If ns <> "" Then MsgBox "单元格" & Target.Address & "新添的数据为:" & ns
    Else
        If ns <> "" Then
            MsgBox "单元格" & Target.Address & "的数据已经改为:" & ns
        Else
            MsgBox "单元格" & Target.Address & "的数据已经删除。"
        End If
    End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Target.Column <> 1 Or Target.Row < 2 Then Exit Sub
    s = Target.Value
End Sub

本文来自用户投稿,不代表顽石财经立场;如侵犯了您的权益,请与本站联系;如若转载,请注明出处:https://www.rocknod.com/1373.html

发表评论

登录后才能评论
QR code