Excel——my_section(分数划分级别)

Function my_section(n1 As String, n2 As Integer) As Integer
    Dim s, i, a, b, c, d, e, f As Integer
    Dim flag As Integer
    
    Dim arr() As Integer
    ReDim arr(10000)
    
    For j = 1 To n2
        s = 0
        For i = 9 To 63
            s = Sheets("成绩页").Cells(j + 3, i) + s
        Next
        arr(j) = s
        If s < 40 Then
            a = a + 1
        ElseIf s < 60 Then
            b = b + 1
        ElseIf s < 70 Then
            c = c + 1
        ElseIf s < 80 Then
            d = d + 1
        ElseIf s < 90 Then
            e = e + 1
        Else
            f = f + 1
        End If
    Next

    
'    If n1 = "40分以下" Then
'            my_section = a
'        ElseIf n1 = "40-60分 " Then
'            my_section = b
'        ElseIf n1 = "60-70分" Then
'            my_section = c
'        ElseIf n1 = "70-80分" Then
'            my_section = d
'        ElseIf n1 = "80-90分" Then
'            my_section = e
'        Else
'            my_section = f
'        End If

If n1 = "40分以下" Then
my_section = a
End If

If n1 = "40-60分" Then
my_section = b
End If

If n1 = "60-70分" Then
my_section = c
End If

If n1 = "70-80分" Then
my_section = d
End If

If n1 = "80-90分" Then
my_section = e
End If

If n1 = "90-100分" Then
my_section = f
End If

End Function
发布了55 篇原创文章 · 获赞 17 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_43213658/article/details/88311886
今日推荐