From the course: Excel: Learning VBA

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Create a subroutine

Create a subroutine

- [Instructor] There are two main types of procedures that you can create in Excel VBA, subroutines and functions. In this movie, I will show you how to create a subroutine, which you can run in the Visual Basic Editor or from your worksheet. My sample file is 01_06_subroutine, and you can find it in the chapter one folder of the exercise files collection. In this workbook, I have some data on the only worksheet commission and I'm going to use in the subroutine that I create the value and cell C7. So remember C7 and I'm going to press Alt F11 to move to the Visual Basic Editor. I'm in the Visual Basic Editor and I don't have any code modules to work with, so I'll go up to the insert menu and click module. There we go. And now I can define the code that I want to use. The keyword for a subroutine is sub and then you can give it a name, so I'll call it calc commission, and then open and close parentheses. The…

Contents