(Solved) – VBA loop function always return 1


Here is my function, I want to create a function to calculate the rank of number, but it always return 1 in ranking. How to fix it, and add “N/A” before it start.

Function Ranking(Score As Double) As Integer

    Dim count As Integer

    Range("C6").Value = "N/A"

    Ranking = 1

    For count = 1 To num_of_students
        If student_records(count, 3) > Score Then
            Ranking = Ranking   1


            Exit For
        End If

    Range("C6").Value = Ranking

    End Function

Leave a Reply

Your email address will not be published. Required fields are marked *