Fill the lstSheets list box

Next, we need to fill the lstSheets list box with a list of all of the sheets in the current workbook. We want this to be done automatically, so we will place the required code in the Initialize event of the UserForm. This event is fired by Excel when the form is loaded, but before it becomes visible. As the name implies, it is designed to initialize various properties of the form and its controls.

Select UserForm in the Object drop-down and Initialize in the Procedures drop-down. You should get the UserForm_Initialize event code shell. Fill it with the code shown in Example 14-3.

0 0

Post a comment