The Close and Open Method in Excel VBA can be used to close and open workbooks. Remember, the Workbooks collection contains all the Workbook objects that are currently open.
VBA Examples
-
-
If you use an Excel macro frequently, you can add it to the Quick Access Toolbar. This way you can quickly access your macro. First, we record an empty macro.
-
This example illustrates the Areas collection in Excel VBA. Below we have bordered the range B2:C3,C5:E5. This range has two areas. The comma separates the two areas.
-
Below we will look at a program in Excel VBA that creates a rolling average table.
-
The type mismatch error in Excel VBA occurs when you try to assign a value to a variable that isn’t of the correct type.
-
As a beginner to Excel VBA, you might find it difficult to decide where to put your VBA code. The Create a Macro chapter illustrates how to run code by clicking on a command button. This example teaches you how to run code from a module.
-
Below we will look at a program in Excel VBA that calculates the total sales of each employee over a period of three years.
-
Below we will look at a program in Excel VBA that creates a User Defined Function. Excel has a large collection of functions. In most situations those functions are sufficient to get the job done. If not, you can create your own function called User Defined Function or custom Excel function. You can access a User Defined Function just like any other Excel function.
-
Instead of multiple If Then statements in Excel VBA, you can use the Select Case structure.
-
You can use a RefEdit control in Excel VBA to get a range from a user. The Userform we are going to create colors the minimum value of the range stored in the RefEdit control.