0% found this document useful (0 votes)
48 views

Customizing The Toolbox

The document discusses various advanced techniques for customizing and programming UserForms in Visual Basic for Applications (VBA). It provides examples of creating modeless dialog boxes, progress indicators, wizards, emulating message boxes, and UserForms with movable and borderless controls. Specific techniques covered include using command buttons, list boxes, multi-page controls, programming dependencies in wizards, and animating labels on a UserForm.

Uploaded by

Kevin Strong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Customizing The Toolbox

The document discusses various advanced techniques for customizing and programming UserForms in Visual Basic for Applications (VBA). It provides examples of creating modeless dialog boxes, progress indicators, wizards, emulating message boxes, and UserForms with movable and borderless controls. Specific techniques covered include using command buttons, list boxes, multi-page controls, programming dependencies in wizards, and animating labels on a UserForm.

Uploaded by

Kevin Strong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Customizing the Toolbox

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
Adding new pages to the Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
Customizing or combining controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
Adding new ActiveX controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
451
Creating UserForm Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . 452
A UserForm
Checklist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453

Chapter 14: UserForm Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


. 455

Creating a UserForm
Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
Using CommandButtons in a UserForm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
Using a ListBox in a UserForm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
Selecting Ranges from a UserForm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . 457
Creating a Splash Screen. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . 459
Disabling a UserForms Close
Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461
Changing a UserForms Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . 462
Zooming and Scrolling a Sheet from a UserForm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. 464
ListBox Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . 466
Adding items to a ListBox control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
Determining the selected item in a ListBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
Determining multiple selections in a ListBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
Multiple lists in a single ListBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
ListBox item transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
474
Moving items in a ListBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
476
Working with multicolumn ListBox controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
Using a ListBox to select worksheet rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
Using a ListBox to activate a sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
Using the MultiPage Control in a UserForm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. 485
Using an External Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . 486
Animating a Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . 489

Chapter 15: Advanced UserForm Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


493

A Modeless Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


. . . 493
Displaying a Progress
Indicator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
Creating a stand-alone progress indicator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498
Showing a progress indicator by using a MultiPage control . . . . . . . . . . . . . . . . . . . . . . . . . 502
Showing a progress indicator without using a MultiPage control . . . . . . . . . . . . . . . . . . . . 505
Creating
Wizards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507
Setting up the MultiPage control for the wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508
Adding the buttons to the wizards UserForm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508
Programming the wizards buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508
Programming dependencies in a wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510
Performing the task with the wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .512

Emulating the MsgBox Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


. . .513
MsgBox emulation: MyMsgBox code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .514
How the MyMsgBox function works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
515
Using the MyMsgBox function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
516
A UserForm with Movable Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. .517
A UserForm with No Title
Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .518

You might also like