Naming Rules of Sub Procedure
- It can start with a letter or an underscore but it cannot start with a number or a special character.
- It cannot contain any space in the name.
- The name of the subprocedure cannot be a keyword like Private, Sub, End, etc.
Syntax
Sub name_procedure ()
End Sub
Let’s discuss different ways to create Sub Procedure:
Sub Procedure in Excel VBA
A Sub Procedure is an action that is written in VBA code. It starts with a Sub statement and ends with an End Sub statement. It is used to manipulate the data in an Excel sheet which includes a table present in an Excel sheet or a pivot table present in the Excel sheet. The name of the procedure should be followed by parentheses. Let’s learn why to use sub procedure:
- Converts large piece of codes into small parts so that the computer ignores all kind of complexities that arises because of large codes
- In a program, we have to access the database frequently. In this case, instead of writing the code again and again we can simply create a function to access the database. Reusability of code can be done.