#NiftyKeyboardShortcuts: Undo (Ctrl + Z)
- markalistairjenner
- Apr 29, 2018
- 2 min read
Help! I didn't mean to do that!
Never fear...unlike most other keyboard shortcuts, Ctrl + Z is there to rescue something that has gone wrong, rather than to do something new. It happens to everyone! And a lot of work with Excel will always be experimental, so a quick undo is something I make frequent use of. In fact, Ctrl + Z is one of those general-purpose shortcuts that works across the Office suite, Gmail and many other places.
Whether editing, applying formatting, switching views or a hundred other actions, Ctrl + Z reverses what has just been done.
It can be applied multiple times to keep on undoing a series of actions, too – although if you’re looking to use the keyboard to undo a lot of actions, a different route might be better. Most Quick Access Toolbars have the Undo command on by default; each QAT command can be accessed using Alt and a number key.
Undo is the third command on my QAT, so I would use Alt + 3 here, followed by holding the down arrow to select multiple actions without needing repeated keystrokes.

Ctrl + Z can also be useful in the process of formula evaluation. If, in the formula bar, you select a section of a formula and press F9, Excel will show you its result.


You can get back to where you were with Ctrl + Z; the formula element will again be selected.
Using the Escape key achieves a similar end, except that it completely exits edit mode, and you would need to make your selection again. If you were to press Enter instead, it will replace that part of the formula with its result.
For VBA users
Ctrl + Z can’t be used in the case of trying to undo actions performed programmatically. Running a macro destroys the Undo stack, so it’s not a universal failsafe! Additionally, using Ctrl + Z within the VBE only undoes up to a maximum of 20 actions.
You can, however, code undo into your macros with the simple line Application.Undo. One possibility is that you could include message boxes, with user responses leading the application to undo actions.
It is often the case that you have to use Application.Undo in combination with turning off Events with the line Application.EnableEvents = False, as performing an undo within Worksheet_Change code is itself a change that would re-trigger the sheet code unless you temporarily disable events in this way. Just remember to turn it back on with Application.EnableEvents = True afterwards!



























Comments