In using Add-In, at first you must install it on your computer then it will always be used for all workbook. In this article, you will be shown how to create custom function in the Add-In using VBA code, save file that contains Add-In, install the Add-In, using custom function from Add-In and uninstall the Add-In.
Body Mass Index is a simple index of weight and height that is commonly used to classify underweight, overweight and obesity in adults. BMI values are age-independent and same for both sexes. The classifications of BMI are showed in the following table:
The BMI scale used here is only suitable for adults aged 20-65 and here is the calculation:
Step 1: Coding VBA Code
- Open Microsoft Excel, then press Alt+F11 on keyboard, so VBE ( Visual Basic Editor) window is displayed.
- Open a module by selecting Module on Insert menu and write this script:Function BMI(weight, height) BMI = weight / (height / 100) ^ 2 End Function
- Close the VBE window and back to Excel. Then save the file with click on Save button or press CTRL+S on your keyboard, so the Save as dialog box is displayed.
Step 2: Save The Excel Workbook
- Fill the name that you want named to at the File Name box. Here I name it BMI Calculation.
- For the file type, choose Excel Add-In (.xlam) format. Then close the workbook.
Step 3: Install The Add-In
- Open Microsoft Excel and select Options by clicking File tab, so Excel Options dialog box is displayed.
- In the Excel Options dialog box, click on Add-Ins tab. Find the Manage option below, choose Excel Add-Ins then click Go.
- Also, you can display the Add-Ins dialog box by click on Developer tab then click Add-Ins.
- On the Add-Ins dialog box, find the Add-In that we want installed to (in this case is BMI calculation), make sure the BMI calculation checkbox is unchecked. Then click OK.
Now, BMI calculation custom function has installed and ready to use.
Step 4: Use The Function
Now, we can use the custom function that we have created. To testing this BMI function, write on the cell B1: =BMI(55,170) , then Press Enter. If the Result is 19.03, it means our custom function is working well. Also you can try calculate your BMI then find out your BMI classification by looking at BMI Classification table.
Step 5: Uninstall The Add-In
However, every Add-In which have installed on Excel, will always running when Excel get started. Excel load time may takes longer than Excel without Add-In. If you don’t need that Add-In anymore, you can uninstall one or more of them. The steps are almost same as installing Add-In, please following this steps:
- Open Add-Ins dialog box by clicking Add-Ins on the Developer tab.
- Choose the Add-In that you want uninstalled to, then uncheck its checkbox.
- Click OK and Restart your Excel.
Community Solutions Content DisclaimerMICROSOFT CORPORATION AND/OR ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY, RELIABILITY, OR ACCURACY OF THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN. ALL SUCH INFORMATION AND RELATED GRAPHICS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT AND/OR ITS RESPECTIVE SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS INFORMATION AND RELATED GRAPHICS, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, WORKMANLIKE EFFORT, TITLE AND NON-INFRINGEMENT. YOU SPECIFICALLY AGREE THAT IN NO EVENT SHALL MICROSOFT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL, CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE, DATA OR PROFITS, ARISING OUT OF OR IN ANY WAY CONNECTED WITH THE USE OF OR INABILITY TO USE THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN, WHETHER BASED ON CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY OR OTHERWISE, EVEN IF MICROSOFT OR ANY OF ITS SUPPLIERS HAS BEEN ADVISED OF THE POSSIBILITY OF DAMAGES.
ID d'article : 2801877 - Dernière mise à jour : 24 sept. 2015 - Révision : 1