Discover the most popular pages, each with a short description. Our Excel VBA course used to be $39 but is now completely free. Happy learning.

1 Run Code from a Module: As a beginner to Excel VBA, you might find it difficult to decide where to put your VBA code. This example teaches you how to run code from a module.

2 Macro Recorder: The Macro Recorder, a very useful tool included in Excel VBA, records every task you perform with Excel. All you have to do is record a specific task once. Next, you can execute the task over and over with the click of a button.

3 Add a Macro to the Toolbar: If you use an **Excel macro** frequently, you can add it to the Quick Access Toolbar. This way you can quickly access your macro.

4 InputBox Function: You can use the InputBox function in Excel VBA to prompt the user to enter a value.

5 Close and Open: 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.

6 Files in a Directory: Use Excel VBA to loop through all closed workbooks and worksheets in a directory and display all the names.

7 Import Sheets: In this example, we will create a VBA macro that imports sheets from other Excel files into one Excel file.

8 Programming Charts: Use Excel VBA to create two programs. One program loops through all charts on a sheet and changes each chart to a pie chart. The other program changes some properties of the first chart.

9 CurrentRegion: You can use the CurrentRegion property in Excel VBA to return the range bounded by any combination of blank rows and blank columns.

10 Entire Rows and Columns: This example teaches you how to select entire rows and columns in Excel VBA. Are you ready?

11 Offset: The Offset property in Excel VBA takes the range which is a particular number of rows and columns away from a certain range.

12 From Active Cell to Last Entry: This example illustrates the End property of the Range object in Excel VBA. We will use this property to select the range from the Active Cell to the last entry in a column.

13 Background Colors: Changing background colors in Excel VBA is easy. Use the Interior property to return an Interior object. Then use the ColorIndex property of the Interior object to set the background color of a cell.

14 Compare Ranges: Learn how to create a program in Excel VBA that compares randomly selected ranges and highlights cells that are unique.

15 Option Explicit: We strongly recommend to use Option Explicit at the start of your Excel VBA code. Using Option Explicit forces you to declare all your variables.

16 Logical Operators: The three most used logical operators in Excel VBA are: And, Or and Not. As always, we will use easy examples to make things more clear.

17 Select Case: Instead of multiple If Then statements in Excel VBA, you can use the Select Case structure.

18 Mod Operator: The Mod operator in Excel VBA gives the remainder of a division.

19 Delete Blank Cells: In this example, we will create a VBA macro that deletes blank cells. First, we declare two variables of type Integer.

20 Loop through Defined Range: Use Excel VBA to loop through a defined range. For example, when we want to square the numbers in the range A1:A3.

21 Do Until Loop: VBA code placed between Do Until and Loop will be repeated until the part after Do Until is true.

22 Sort Numbers: In this example, we will create a VBA macro that sorts numbers. First, we declare three variables of type Integer and one Range object.

23 Remove Duplicates: Use Excel VBA to remove duplicates. In column A we have 10 numbers. We want to remove the duplicates from these numbers and place the unique numbers in column B.

24 Debugging: This example teaches you how to debug code in Excel VBA.

25 Error Handling: Use Excel VBA to create two programs. One program simply ignores errors. The other program continues execution at a specified line upon hitting an error.

26 Subscript Out of Range: The 'subscript out of range' error in Excel VBA occurs when you refer to a nonexistent collection member or a nonexistent array element.

27 Separate Strings: Let's create a program in Excel VBA that separates strings. Place a command button on your worksheet and add the following code lines.

28 Instr: Use Instr in Excel VBA to find the position of a substring in a string. The Instr function is quite versatile.

29 Compare Dates and Times: This example teaches you how to compare dates and times in Excel VBA.

30 DateDiff Function: The DateDiff function in Excel VBA can be used to get the number of days, weeks, months or years between two dates.

31 Highlight Active Cell: Learn how to create a program in Excel VBA that highlights the row and column of the Active Cell (selected cell). This program will amaze and impress your boss.

32 Dynamic Array: If the size of your array increases and you don't want to fix the size of the array, you can use the ReDim keyword. Excel VBA then changes the size of the array automatically.

33 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 use Excel VBA to create your own function.

34 Read Data from Text File: Use Excel VBA to read data from a text file. This file contains some geographical coordinates we want to import into Excel.

35 Vlookup: Use the WorksheetFunction property in Excel VBA to access the VLOOKUP function. All you need is a single code line.

36 List Box: Use Excel VBA to place a list box on your worksheet. A list box is a list from where a user can select an item.

37 Check Box: A check box is a field which can be checked to store information. To create a check box in Excel VBA, execute the following steps.

38 Loan Calculator: This page teaches you how to create a simple loan calculator in Excel VBA. The worksheet contains the following ActiveX controls: two scrollbars and two option buttons.

39 Currency Converter: Use Excel VBA to create a Userform that converts any amount from one currency into another.

40 Progress Indicator: Learn how to create a progress indicator in Excel VBA. We've kept the progress indicator as simple as possible, yet it looks professional. Are you ready?

Browse all Excel VBA examples.