【发布时间】:2020-01-03 13:39:03
【问题描述】:
我正在尝试创建一个输入框循环,其中每个输入框都包含 A 列中单元格的内容,并且所要求的输入应在其旁边的单元格中结束(B 列);如图所示。好消息(对我来说)是循环有效,但是在我填写了每个输入框后,宏只注册整个范围内的最后一个条目(在这种情况下未批准,而例如前两个条目已“批准” ”)。你能帮我一把吗?提前致谢! (代码如下)。
Sub inputresults()
Dim myvalue As Variant
Dim c As Range, rngc As Range, i As Long, lrow As Long
i = 3
lrow = Cells(Rows.Count, "A").End(xlUp).Row
Set rngc = Range(Cells(lrow, "A"), Cells(i, "A"))
For Each c In rngc
myvalue = InputBox(c)
Next
Dim cl As Range, clrng As Range, lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set clrng = Range(Cells(lastrow, "B"), Cells(i, "B"))
For Each cl In clrng
cl.Value = myvalue
Next
End Sub
【问题讨论】: