How to add text to last row of a column

非 Y 不嫁゛ 提交于 2020-01-03 05:37:09

问题


Please I need some help with how to add text to the last (empty) row in a column using VBA?

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.

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.


回答1:


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

It will locate the first empty cell below all data in column A and place the C3 value in it.




回答2:


Try code such as the following:

Sub MoveFromCToA()
    Cells(rows.count,1).end(xlup).offset(1).value = cells(3,3)
End Sub


来源:https://stackoverflow.com/questions/30308914/how-to-add-text-to-last-row-of-a-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!