How to Customize VBA Userform

Customize a VBA userform by adding and deleting controls on the form, changing the properties of those controls, and changing the location of controls. Customizing userforms lets you adapt them to the VBA programs linked to those forms. Another reason to customize userforms is to create visual styles appropriate for a new group of users. For example, if you need to adapt your program for usage by new computer users, you may hide or remove some of the controls on the program's userform to reduce confusion.

Instructions

    • 1

      Open Windows Explorer, then double-click a Word, Excel, or other Office document containing an existing VBA userform you'd like to customize. Your Office application will open the document you selected.

    • 2

      Click your application's "Developer" tab, then click the "Visual Basic" button to enter the VBA programming environment. Click the "Userform" item in the Project pane to display the userform for editing.

    • 3

      Click a control on the userform, such as a command button or a list box control. Press "Delete" to delete the control. Click the "Toolbox" palette icon for a control you want to add, such as the small rectangle representing the command button control. Click the location on the userform to which you'd like to insert the control, then drag to indicate the area the control will occupy. Release the mouse to insert the control on the userform.

    • 4

      Right-click a control on the userform, then click "Properties" to display the Properties panel, which lets you set set values that impact the behavior and appearance of userform controls. Click the right column of a property you'd like to change. For example, click the right column of the "Fore Color" property to enter the area for changing the color of a control's display text. To learn about a control property, press F1 after clicking the right column of any property to display help for that property.

    • 5

      Type the new value for the property. For example, to change the selected control's foreground text to red, type "255," which VBA interprets as the color red.

    • 6

      Right-click the toolbar, then click "Userform" to display a new palette with options that let you align and arrange userform controls. Click a control you'd like to align with another control, then press and hold the Shift key. Click the control you'd like to align the selected control with, release the Shift key. Click one of the alignment controls from the Useform palette, such as "Align Lefts." VBA will change the position of the controls to perform your request.

Related Searches:

References

  • "Mastering VBA for Office 2010"; Richard Mansfield; 2010

Comments

Related Ads

Featured