实例:
Sub Add10ToAllCellsInRange()
Dim rng As Range
For Each rng In Range("A1:A10")
rng.Value = rng.Value + 10
Next
End Sub
实例2:
Sub TestForNumbers()
For Each rng In Range("A1:B5")
If IsNumeric(rng.Value) = False Then
MsgBox "Cell " & rng.Address & " contains a non-numeric value."
Exit For
End If
Next rng
End Sub
参考:https://learn.microsoft.com/zh-tw/office/vba/language/concepts/getting-started/using-for-eachnext-statements