Vba forms creation in Excel

In the previous chapter, we learned about Graphical User Interface basics.

GUI is nothing but a visual interface which displays various controls like buttons, textboxes and so on.

Form is nothing but a container that holds these controls.

GUI is not possible without forms.

In short, Form is the container for all controls that make up the user interface.

Forms are sometimes called as Windows.

The following figure shows a form in VBA.

excel vba forms creation

As seen from the above, the form holds various controls like textbox,Labels.

Thus the form makes up the GUI.

A form has various events associated with it, some of which are as discussed below.

Initialize Event

This event is triggered whenever a form is opened for the first time.

The syntax for this event is as below:

excel vba forms creation

Activate Event

This event is triggered whenever the form is activated are focussed.

This differs from Initialize event in the sense that, this event is triggered everytime the form becomes active, including the first time.

The syntax is as follows:

excel vba forms creation

Click Event

This event is activated whenever the user form is clicked.

The syntax of this event is as shown below:

excel vba forms creation

 

You can find similar Excel Questions and Answer hereunder

1) I have a WorkBook that loads a form automatically when it is opened. In Excel, how can I suppress the form from loading on file open when required?

2) I have data arranged in rows of information. Is there any way I can enter new data through a form instead of entering it directly in SpreadSheet?

3) How can I display list of NAMES in a worksheet?

4) How can I export a chart as a gif file?

5) How can I make my macro wait for 5 secs before executing the next command?

6) How can I find the day of the week given a date?

7) Here some more advanced range objects and what you can do with the range object in VBA

8) Here an explanation about label controls in the various forms and controls using VBA

9) How can I convert Column numbers into Column names for use in range definition?

10) How can I remove Outline from my WorkSheet?

 

Here the previous and next chapter