View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen[_2_] Per Jessen[_2_] is offline
external usenet poster
 
Posts: 703
Default Guidance, please (xl2007)

Hi Kragelund

To use a worksheetfunction in a macro use this syntax:

Application.WorksheetFunction.Min(....

Regards,
Per

On 7 Dec., 23:43, Kragelund
wrote:
Problem: when I run the sub, I get the message "sub or function not defined",
the problem appears to be related to the statement assessing, which is the
minimum value. Cant I use the Min statement like this, or where might the
trouble be?

Thx very much!

Code:

Sub Optimize_pension_A()

Dim startyear, number_yrs As Integer
Dim potential, max_finansing, maks_contribution As Single

h = 1 * * * * * * * * * * * * * * * * * * * * * * * ' contant used in function
i = 0
startyear = cells(78, 2).Value * * * * * * * * * * * *'startyear
number_yrs = cells(3, 10).Value - cells(6, 10).Value *'years to retirement,
person A
max_contribution = 45300 * * * * * * * * * * * * * *
max_financing= cells(69, 2).Value * * * * * * *'(budgetdeficit)

For i = 0 To number_yrs

If cells(60, 2 + i).Value 0 Then potential= Min(max_contribution,
(cells(60, 2 + i))) Else Exit For

cells(80, 2 + i).Value = -potentiale

finansing = cells(99, 2 + i).Value
If finansing <= max_finansing Then Result = Find_finansiering_A(cells(80, 2
+ i), cells(99, 2 + i)) Else

Next i

End Sub