Iki
Iki

Reputation: 119

How to add text to last row of a column

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.

Upvotes: 0

Views: 19391

Answers (2)

Gary's Student
Gary's Student

Reputation: 96791

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.

Upvotes: 2

basodre
basodre

Reputation: 5770

Try code such as the following:

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

Upvotes: 0

Related Questions