这个编码怎么了?它在单个细胞中工作,但不在多个细胞中工作
Private Sub CommandButton1_Click()
Dim marks As Integer, result As String
marks = range("B2:B7")
If marks >= 33 Then
result = "pass"
Else
result = "fail"
End If
range("C2:C7").Value = result
End Sub
答案 0 :(得分:1)
也许你正在努力实现这个......
Private Sub CommandButton1_Click()
Dim Rng As Range, Cell As Range
Set Rng = Range("B2:B7")
For Each Cell In Rng
If Cell >= 33 Then
Cell.Offset(0, 1) = "Pass"
Else
Cell.Offset(0, 1) = "Fail"
End If
Next Cell
End Sub