|
This page is one of the 33 lessons from the
Tutorial on VBA for Excel (Macros)
VBA for Excel made simple
VBA Lesson 3-5: The Labels in VBA for Excel
(Levels: Intermediate)
In the toolbox the label has this icon . The label is a passive control meaning that the user never really acts on it. It is there to inform the user and to label other controls like text boxes, combo boxes or list boxes.
Properties
The other interesting properties of the label are:
- TabStop: To make the control invisible for the "Tab" and "Enter" keys (see Tab Order) set this property to "False" . - WordWrap: If you want to write more than one line of text in a label set this property to "True" .
Code
There is not much coding developed for the labels although there are 8 events related to the label. For example there is an event named "MouseMove" . If you develop code within this event it is executed when the mouse moves over the label. If the code is the following:
MsgBox "Don't forget to..."
a message box will appear when the user moves the mouse over the label.
You can stack many labels one over the other and make their "Visible" property to "False" . You can then make any of the label visible from an event related to another control. For example if a user chooses a certain value in a combo box a certain label appears.
This page is one of the 33 lessons from the
Tutorial on VBA for Excel (Macros)
VBA for Excel made simple
|