Polynom calculation. Help. My code doesn't work
- Write a Public Function named “FunctionValues”, which takes values of vector x from the specified cells (array) and calculate the function f(x) = x^2 + 1/2x + 2 for all values (array). The function should have one parameter (type array) and will return one array with the same dimension as parameter. Provide some example of using such a function in the worksheet. Please note that it should be programmed as a function and not subroutine!!!
Code:
Dim Row As IntegerDim Column As Integer
MyArray = Range("A1:C3")
Row = InputBox(Prompt:="Row")
Column = InputBox(Prompt:="Column")
If Row < 3 And Column < 3 Then
MsgBox "Item on row " & Row & " and column " & Column & " is " & MyArray(Row, Column)
Else
MsgBox "There is no such item"
End If
End Sub
Public Function Polyn(Rin As Range) As Double
Dim v As Variant
v = Rin.Value
Polyn = x ^ 2 + 1 / 2 * x + 2
End Function