Undo in VBA code


Posted by Rachel on October 29, 2001 11:08 AM

How can i use the undo action in VBA code, to return
the previous content of a cell when it change to
un appropriate value?

Posted by William Liddell on October 29, 2001 1:48 PM


The last manual entry can be "undone" by :-
Application.Undo

For instance if you wanted to prevent values greater than 1 being manually input to A1 :-

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, [A1]) Is Nothing Then
If [A1] > 1 Then Application.Undo
End If
End Sub




Posted by Rachel on November 03, 2001 7:21 AM

William,
Thanks a lot.
Rachel