使用Excelmacros分配成绩
我在Column9
有我的成绩,我必须为Column 10
每个学生分配一个成绩。 这是我的Excelmacros代码。
Sub grading() Dim k As Integer Dim result As String For k = 2 To 6 If (Cells(k, 9) >= 75) Then result = "A" ElseIf (Cells(k, 9) >= 65) Then result = "B" ElseIf (Cells(k, 9) >= 55) Then result = "C" Else result = "F" End If Cells(i, 10).Value = result Next k End Sub
但是这给运行时错误:
应用程序定义或对象定义的错误。
这是什么问题? 这是我的第一个macros,所以我会感谢一些帮助。
sam_rox。
你的代码中有一个小错误:
Cells(i, 10).Value = result
应该 :
Cells(k, 10).Value = result
似乎这个修改后正常工作。