validation单元格并获得评分

这是我的要求。 我有B列有标记的表格。 基于标记和点击一个button,我试图获得成绩和基于年级的单元格颜色。 以下是我写的代码,但这是不成功的工作。 请帮忙

Sub SetGrade() Dim r As Integer Dim Score As Double For r = 2 To 20 Score = Cells(r, 2).Value If Score >= 90 And Score <= 100 Then ActiveCell(1, 2).Value = "A" ActiveCell(1, 2).Interior.ColorIndex = 4 ActiveCell(1, 2).HorizontalAlignment = xlCenter ElseIf Score >= 75 And Score <= 90 Then ActiveCell(1, 2).Value = "B" ActiveCell(1, 2).Interior.ColorIndex = 46 ActiveCell(1, 2).HorizontalAlignment = xlLeft End If Next r End Sub 

我认为你真正需要做的是摆脱这样的activecell:

 Sub SetGrade() Dim r As Integer Dim Score As Double For r = 2 To 20 Score = Cells(r, 2).Value If Score >= 90 And Score <= 100 Then Cells(r, 3).Value = "A" Cells(r, 3).Interior.ColorIndex = 4 Cells(r, 3).HorizontalAlignment = xlCenter ElseIf Score >= 75 And Score <= 90 Then Cells(r, 3).Value = "B" Cells(r, 3).Interior.ColorIndex = 46 Cells(r, 3).HorizontalAlignment = xlLeft End If Next r End Sub