[code]
Sub test() '定义一个执行函数
Range("a:d").Clear
Range("a1").Value = "id"
Range("b1").Value = "score"
Range("c1").Value = "及格否"
Range("d1").Value = "等级"

Dim i, st As Integer '声明变量i,st,'代表注释

For i = 2 To 10 'for循环
Range("a" & i).Value = i - 1
Range("b" & i).Value = "=randbetween(0,100)"
Next 'for循环结束

‘录制宏:复制b列,然后黏贴123,即可去掉randbetween,避免=的时候每次自动执行换数
Range("B2:B10").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

For i = 2 To 10
st = st + Range("b" & i).Value ‘&相当于+连接符

If Range("b" & i).Value >= 60 Then
Range("c" & i).Value = "pass"
Else
Range("c" & i).Value = "fail"
End If

’相当于c语言中的switch...case...
Select Case Range("b" & i).Value
Case Is > 90
Range("d" & i).Value = "A"
Case 60 To 90
Range("d" & i).Value = "B"
Case Else
Range("d" & i).Value = "C"
End Select

Next
Range("b11").Value = "total:" & st

End Sub

][/code]