Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

BeginUndo Method

Specifies the beginning of an undo block. This means that all statements between this call and its corresponding EndUndo 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.BeginUndo

expression   An expression that returns a ChartSpace or Spreadsheet object.

Example

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.
    Spreadsheet1.BeginUndo

        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.
    Spreadsheet1.EndUndo
End Sub

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.