15 Advanced UserForm Techniques

In This Chapter

  • Using modeless UserForms
  • Displaying a progress indicator
  • Creating a wizard — an interactive series of dialog boxes
  • Creating a function that emulates VBA’s MsgBox function
  • Allowing users to move UserForm controls
  • Displaying a UserForm with no title bar
  • Simulating a toolbar with a UserForm
  • Emulating a task pane with a UserForm
  • Allowing users to resize a UserForm
  • Handling multiple controls with a single event handler
  • Using a dialog box to select a color
  • Displaying a chart in a UserForm
  • Creating puzzles and games with Userforms

A Modeless Dialog Box

Most dialog boxes that you encounter are modal dialog boxes, which you must dismiss from the screen before the user can do anything with the underlying application. Some dialog boxes, however, are modeless, which means the user can continue to work in the application while the dialog box is displayed.

To display a modeless UserForm, use a statement such as:

UserForm1.Show vbModeless

The keyword vbModeless is a built-in constant that has a value of 0. Therefore, the following statement works identically:

UserForm1.Show 0

Figure 15.1 shows a modeless dialog box that displays information about the active cell. When the dialog box is displayed, the user is free to move the cell cursor, activate other sheets, and perform other Excel actions. The information displayed in the dialog box changes when the active cell changes.

Figure 15.1 This modeless dialog box remains visible while ...

Get Excel 2016 Power Programming with VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.