Hi
So what?
In general:
Function MyFunc(Parameter1 As Par1Type, ...) As RetValType
' Volatile is needed to make the function react immediately to changes
on worksheet
Application.Volatile
' You can have any number of command lines (code), you need to calculate
the return value, here. But beware that nothing in workbook is changed -
changing active cell or sheet, or overwriting cell vlaues or formats etc.
are not allowed in functions
[Your code]
'Return value must be saved to variable with name same as function name,
in last code row
MyFunc=LastExpression
End Function