如果你真的想要一个VBA解决方案,您可以依次通过一系列这样的:
Sub Check()
Dim dat As Variant
Dim rng As Range
Dim i As Long
Set rng = Range("A1:A100")
dat = rng
For i = LBound(dat, 1) To UBound(dat, 1)
If dat(i, 1) <> "" Then
rng(i, 2).Value = "My Text"
End If
Next
End Sub
*编辑*
而不是使用一些变体中你可以通过这样的范围内循环:一个简单的方法来做到
Sub Check()
Dim rng As Range
Dim i As Long
'Set the range in column A you want to loop through
Set rng = Range("A1:A100")
For Each cell In rng
'test if cell is empty
If cell.Value <> "" Then
'write to adjacent cell
cell.Offset(0, 1).Value = "My Text"
End If
Next
End Sub
你试过什么了吗?循环播放,直到在本网站上多次询问下一个空白单元格... –
^^好几次... –
为什么不直接输入您的公式和自动填充? –