如何将文本添加到列的最后一行 [英] How to add text to last row of a column
问题描述
在使用VBA将文本添加到列的最后一行(空)时,我需要一些帮助吗?
Please I need some help with how to add text to the last (empty) row in a column using VBA?
我有一个带有ActiveX控件按钮的表单.我希望在单击命令按钮时,Excel接受单元格C3中包含的文本,并将其添加到A列的最后一个(空)行中.
I have a spreedsheet with an ActiveX Control button on it. I want that on clicking the command button, Excel takes the text contained in say, cell C3, and add it to the last (empty) row of column A.
请注意,列A已在各个单元格中包含文本.我想做的是找到最后一个空单元格,然后将文本从单元格C3传输到最后一个空行.谢谢.
Please note that Column A already contains text in various cells. What I want to do is find the last empty cell and then transfer the text from cell C3 to this last empty row. Thank you.
推荐答案
将此宏分配给您的按钮:
Assign this macro to your button:
Sub ButtonCode()
Dim N As Long
N = Cells(Rows.Count, "A").End(xlUp).Row + 1
Cells(N, "A").Value = Range("C3").Value
End Sub
它将在 A 列中所有数据下方找到第一个空白单元格,并将 C3 值放入其中.
It will locate the first empty cell below all data in column A and place the C3 value in it.
这篇关于如何将文本添加到列的最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!