Making a first Visual Basic function for Excel

Viewed 57

This is the first time I research about Visual Basic programming language but, as it is the language used to make functions in excel, I need to know.

I have written the following function.

Function getNMinMax(cell As Integer) As Integer
    Dim res As Integer = 0
    For n As Integer = 8 To 1 Step -(n/2)
        res = res + n
    Next n
End Function

But according to Excel, it is syntactically incorrect since the second line of code. Besides, this kind of error also happens in some of the next lines.

Any idea about what are the syntax errors in my function? Is there any chance to make functions in excel files by using any other programming language like C or Java?

I would appreciate any possible solution.

Thank you and regards.

0 Answers
Related