In: Computer Science
(EXCEL) Create a user-defined function called Hexagon that takes one argument called side and returns the area of a regular hexagon given the length of the side. Show that the function works in a worksheet by inserting the formula somewhere.
Step 1 : Open EXCEL and press ALT + F11 to get into visual basic editor.
Step 2 : Choose Insert -> Module in the editor.
Step 3 : Here we need to type the programming code
We take argument side as double type
and, area = (3 *sqrt(3) *a^2)/2 i.e area of regular hexagon
square root can be return in form of power 1/2.
Then we save the function and return to excel.
Step 4: Click the Insert Function button on the Formulas tab to display the Insert Function dialog box.
Then , click on the function you created , i.e AreaOfRegularHexagon
Step 5 : Then , input the length of the side
For example , side = 6 and click OK.
Finally , its done . This value appears on the sheet.