Goalseek metode - Excel
Hejsa,Jeg skal programmere den samme funktion som man kan benytte i en Excel Makro.
Goalseek metoden.
Her er udskrift fra hjælp menuen..
#1 *******************************************************************
GoalSeek Method
Calculates the values necessary to achieve a specific goal. If the goal is an amount returned by a formula, this calculates a value that, when supplied to your formula, causes the formula to return the number you want. Returns True if the goal seek is successful.
Syntax
expression.GoalSeek(Goal, ChangingCell)
expression Required. An expression that returns a Range object. Must be a single cell.
Goal Required Variant. The value you want returned in this cell.
ChangingCell Required Range. Specifies which cell should be changed to achieve the target value.
#2 *******************************************************************
GoalSeek Method Example
This example assumes that Sheet1 has a cell named "Polynomial" that contains the formula =(X^3)+(3*X^2)+6 and another cell named "X" that’s empty. The example finds a value for X so that Polynomial contains the value 15.
Worksheets("Sheet1").Range("Polynomial").GoalSeek _
Goal:=15, _
ChangingCell:=Worksheets("Sheet1").Range("X")
**********************************************************************
Jeg forestiller mig lidt alá det her, men jeg kan ikke få det til at virke:
'## BEREGNER WAC UD FRA GOAL-SEEK METODEN
'## KONTANTRENTEN FOR 4 TERMINER
function FindWAC()
dim intInc, intConstC35, intConstC11
intConstC35 = C35()
intInc = 0.5
intConstC11 = 1
'GoalSeek method
do until (intConstC35 < 0.0005)
If intConstC35 < (intInc * 1000000000) Then
intInc = intInc / 5
End If
FindWac = intConstC11 + intInc
'## BEREGN NY VÆRDI AF C35
intConstC35 = C35()
loop
End function
