Undo Method Example

This example undoes the last action or displays a message box if this action cannot be undone.

If Spreadsheet1.CanUndo Then
    Spreadsheet1.Undo
Else
    MsgBox "can't undo last action"
End If