Microsoft Excel is not only a spreadsheet application, it has far more functionality. One of those is the ability to work with Visual Basic to create interactivity. In this tutorial we will work on excel forms and VBA and we will learn how to use excel vba to close form.
Step # 1 – Button setup
This is a particularly easy task as it involves writing a small statement. But before that, we must have a button created on that form.
For inserting a button, we have to go to “Insert” Menu and click “User Form”.
After that we can Use the toolbox to drag and drop a button.
Let’s name the button as “Save and close”.
The image below shows excel forms and vba.
Step # 2 – Unloading myself
Once the prerequisite is complete we will now tell the form to close on the press of the button. To do this we will double click on the button. This opens a new window with a sub routine already created for the button click event. Here we will write a small statement, the Unload Me command.
Since the form is supposed to close itself, it will use the Me keyword present in Visual Basic, otherwise the name of the form would have been written in its place.
And this was all about how we can use excel vba to close form.