Simple Function in Excel VBA

Here are the steps: 

Step 1: Open an Excel Workbook; choose DeveloperVisual Basic, A Visual basic editor will appear

file

Step 2:

In the project window we can see list of opened excel workbook. Choose the current workbook and create a module shown in the below image.

module

Step 3:

After create the module create a function like below. (The below function is allows to add two cell values.)

Function Addition(a As Integer, b As Integer) As Integer

Addition = a + b

End Function


Step 4:

After creating the function, go to the Excel sheet and call the function like shown in the image and then press enter, it will show the result on the cells where formula have been entered.

formula

The final result will be,

result