This can also work on a range of cells and if your unsure of how to change
it to do that then post back.
Private Sub Worksheet_Change(ByVal Target As Range)
If IsEmpty(Target) Then
If Target.Address = "$A$1" Then
MsgBox "Do something"
End If
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Set a1 = Range("A1")
Set t = Target
If Intersect(a1, t) Is Nothing Then
If a1.Value = "" Then
wasblank = True
Else
wasblank = False
End If
Exit Sub
Else
If wasblank And a1.Value <> "" Then
MsgBox ("changed from blank to nonblank")
wasblank = False
End If
If a1.Value = "" Then
wasblank = True
End If
End If
End Sub
This should do what you want. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
Dim OldValue As Variant
Dim NewValue As Variant
If Target.Count > 1 Then Exit Sub
NewValue = Target.Value
Application.EnableEvents = False
Application.Undo
OldValue = Target.Value
Target.Value = NewValue
Application.EnableEvents = True
If OldValue = "" Then
'Do your thing here
End If
End Sub
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.