EndUndo Method

Specifies the end of an undo block. This means that all statements between this call and its corresponding BeginUndo method call will be undone by a single call to the Undo method. This makes it possible for you to combine entire macros into one statement that can be easily undone. Undo blocks can be nested.


*expression   * An expression that returns a ChartSpace or Spreadsheet object.


This example creates an undo block containing code that sets the number format and font for cell D10. You can undo all of the formatting by clicking Undo on Spreadsheet1's toolbar.

Sub UndoBlock()
    Dim rngCurrent
    ' Enable undo.
    Spreadsheet1.EnableUndo = True
    ' Start an undo block.
        Set rngCurrent = Spreadsheet1.Worksheets("sheet1").Range("D10")
        ' The following three lines of code apply
        ' various formatting to cell D10.
        rngCurrent.NumberFormat = "0.###"
        rngCurrent.Font.Color = "Blue"
        rngCurrent.Font.Name = "Times New Roman"
    ' End the undo block.
End Sub

Applies to | ChartSpace Object | Spreadsheet Object

See Also | BeginUndo Method | EnableUndo Property | Undo Method