Body Mass Index (BMI) is so popular today that it has become a standard measure for our health status. If your BMI is too high, it means you are overweight and would likely face a host of potential health problems associated with high BMI, such as hypertension, heart disease, diabetics and many others. We have programmed a BMI calculator using Visual Basic 6 before, but now we shall show you how to create an Excel VBA BMI calculator in MS Excel. The code is as shown below:
|
Explanation:
The formula for calculating BMI is
BMI=wieght(/(height2)
The function Round is to round the value to a certain decimal places. It takes the format Round(x,n), where n is the number to be rounded and n is the number of decimal places.
The second part of the program uses the If...Then..Else statement to evaluate the weight level. The output is as shown in Figure 13.1
Figure 13.1
Copyright ® 2008 Dr.Liew Voon Kiong . All rights reserved
Contact: admin@excelvbatutor.com [Privacy Policy]
กก