To stat developing a new formula in Excel, open the application and press Alt + F11 if you're using a Windows system. If you're using Mac, press Fn + Option + F11. This action opens the Visual Basic Editor, that allows you to extend the functionality of the application.
Next, after displaying the Visual Basic Editor window, click Insert drop-down menu and select Module, like it is shown in the following screenshot:
Next, you need to insert the following syntax in the newly displayed window:
Function <Name of function>(Parameter1, Parameter2)
Firstly, you write Function and then you need insert the name of the function. Note that you don't need to put the comparing symbols. I put them to show you that what's there requires your input. Secondly, in the parenthesis, you need to write the inputs of your function. In our case, the inputs will be Height and Weight.
After you press Enter, notice that the End of the Function argument is automatically placed at the end of the custom function.
Next, you need write the function's formula, so in our case, the result will be the following:
<Name of function> = (Weight)/(Height * Height)
The final function should look like the following:
Function BodyMassIndex(Weight, Height)
BodyMassIndex = (Weight) / (Height * Height)
End Function
Save your result and go to your spreadsheet to test the newly created function.
Click on the Fx button to open the Insert Function dialog box. Select All on the Or select a category drop-down menu, and search for the new function. Select it, and click OK. You will be prompted to input your weight and height. After completing this step, click OK and notice that the result is generated.
If you're using the imperial system, note that the result from the division between Weight (in lbs) and Height (in inches) should be multiplied with 703 to get the final result.
I hope this tutorial improved your knowledge in creating custom functions in Excel. Please submit your feedback by posting a comment below.
See you at the next tutorial!