You are on page 1of 4

Cell ‘h15’

Cell ‘h16’

Macro Code to use GoalSeek

Sub ZcalcDAKEoS()

Range("h15").GoalSeek Goal:=0, ChangingCell:=Range("h16")

End Sub

Notes
1. Cell ‘h15’ contains the formula, whereas cell ‘h16’ contains the value to be changed to bring difference
between RHS and LHS of the equation to 0.0
2. To assign a button and put the above Macro code, follow below
1. In MS-Excel, Click File -> Options ->Add-Ins -> Go.
2. Select “Analysis ToolPak” and “Analysis ToolPack – VBA”
3. Click OK

1. On the File tab, go to Options > Customize Ribbon.


2. Under Customize the Ribbon and under Main Tabs, select the Developer check box. Click Ok
1. In the main excel window a new tab opens up called developer from where the ‘button’ can be added. Draw a
button & right click on it to get the Assign Macro option. Create a New Macro with a name e.g. DAKEoS’ and
enter the above code.

Next: Add a Button

Next Step: After drawing a button. Right click on it and click Assign Macro

Next: Click New. Enter a Macro name. Click Ok.

Next Step: On the Ribbon, Under Design, Select Macros


Next Step: Select the Macro Name and Click on ‘Edit’

Next Step: Copy Paste the Macro Code Given on Page 1 and change the cell numbers appropriately

Save the File as xyz.xlsm. It is a must to save the file as *.xlsm to enable macros.

You might also like