This article is part of my series: VBA & Macros in Excel – A Step by Step Complete Guide and Make UserForms in VBA Excel with Total 6 Tutorials.
When you have worked with Excel dialog boxes, sometimes you have used accelerator( shortcut) keys and tabs to perform your job. In this article, I shall show how to add Accelerator keys and control tab order in custom UserForms.
Adding accelerator keys in Excel UserForm
You will find many people who prefer to use a keyboard rather than a mouse. Your custom dialog boxes should have this additional advantage for the keyboard lovers. Your all dialog boxes should function equally well with a keyboard and a mouse. The user will press Alt + the accelerator key to work with a dialog box control.
To add an accelerator key for a control in the UserForm, just enter a character for the Accelerator property of the relevant control. The letter can be any in the caption of the control object- not necessarily it should be the first letter.
If you have assigned an accelerator key for two controls in the UserForm, first control will be activated with the first press of that key, next press of that key will activate the second control.
Controlling tab order in Excel UserForm
When you’re working with a UserForm, pressing Tab and Shift+Tab cycles through the dialog box’s controls. You should make sure that the tab order is correct, when you create your custom UserForm. Usually, it means that tabbing should move through the controls in a logical sequence.
To view or change the tab order in a UserForm, choose View ➪ Tab Order to display the Tab Order dialog box. Select a control from the list; then use the Move Up and Move Down buttons to change the tab order for the selected control. See below.
Happy Excelling ☕