隨機產生五十筆分數,並分類A~E
Public Sub 標題加分數()
Range("A1").Value = "編號"
Range("B1").Value = "分數"
Range("C1").Value = "等第"
Range("D1").Value = "及格確認"
Dim randomScore As Integer
For i = 1 To 50 Step 1
Range("A" & i + 1).Value = i
randomScore = Rnd * 90 + 10
Range("B" & i + 1).Value = randomScore
Select Case Range("B" & i + 1).Value
Case 90 To 100
Range("C" & i + 1).Value = "S"
Range("C" & i + 1).Font.Color = RGB(0, 255, 255)
Case 80 To 89
Range("C" & i + 1).Value = "A"
Case 70 To 79
Range("C" & i + 1).Value = "B"
Case 60 To 69
Range("C" & i + 1).Value = "C"
Case 0 To 59
Range("C" & i + 1).Value = "D"
Range("C" & i + 1).Font.Color = RGB(255, 0, 0)
End Select
If Range("b" & i + 1).Value >= 60 Then
Range("d" & i + 1).Value = "及格"
Range("d" & i + 1).Font.Color = RGB(0, 0, 0)
Else
Range("d" & i + 1).Value = "不合格"
Range("d" & i + 1).Font.Color = RGB(255, 0, 0)
End If
Next
End Sub
沒有留言:
張貼留言