Macro to use goal seek with criteria

SRpakse

New Member
Joined
Nov 25, 2015
Messages
31
Hi All,

I am after a macro that will help me use the goal seek function to determine Gross Margin % and Net Profit % for a very basic profit and loss summary. The GM% and NP% needs to change as they are changed in other cell references (I.e there will be input cells to change these numbers).Once the criteria for GM% and NP% are set the goal seek function should change the sales figure based on these percentages. I would not mind having two separate scenarios as I don't want to change to many variable. So maybe one macro for GM% and one Macro for NP%?.Sample shown below.

Sales $50

Cogs $20

GM $30

GM% 60%

Exp $10

NP $20

NP% 40%

The 60% gross margin and 40% gross margin needs to change with the values in the input cells and the sales number needs to change too. For Example if a GM% of 80% is required then the macro would change the sales figure to $99.58092 and the net profit margin dollar value to $69.58092 and net profit margin to 70%

Is this even possible using a macro?

Thanks
SR
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi,

Not a full proof solution but just some pieces to get you started. Take a look at this;

Book1
ABCDE
1Sales33,32886required GM10%
2required NP10%
3Cogs20
4
5GM13,32886
6
7GM%40%
8
9Exp10
10
11NP3,328855
12
13NP%10%
Sheet1
Cell Formulas
RangeFormula
B5=B1-B3
B7=B5/B1
B11=B5-B9
B13=B11/B1


Code:
Sub Change_GM_NP()
'
Dim Response As Integer

    Response = MsgBox(prompt:="Wish to change GM", Buttons:=vbYesNo)
    If Response = vbYes Then
         Req_GM = Range("E1").Value
         Range("B7").GoalSeek Goal:=Req_GM, ChangingCell:=Range("B1")
    End If
    Response = MsgBox(prompt:="Wish to change NP", Buttons:=vbYesNo)
    If Response = vbYes Then
         Req_NP = Range("E2").Value
         Range("B13").GoalSeek Goal:=Req_NP, ChangingCell:=Range("B1")
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,855
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top