VBA: Write Data After Last Row Used in a Column

August 17th, 2004 | Categories: VBA | Tags:
-->

Using VBA you may need to write to the first empty cell, or after the last row used in a column. There is no need to loop to find this, the following code does it for you.

In this example the code will write “FirstEmpty” in the first empty cell in column “d”

Public Sub AfterLast()

ActiveSheet.Range("d" & ActiveSheet.Rows.Count) _
    .End(xlUp).Offset(1, 0).Value = "FirstEmpty"

End Sub
Can't get the tutorial to work for you? Need help with your code?
Get answers right away at our AE Excel Support Forums!
  1. Tissa
    July 28th, 2005 at 19:12
    Reply | Quote | #1

    Hi,
    If you have say 5 values in a column with different gap between them for example a name (x) in c2 then y in c5 then z in c12 and so on and want to fill down to the next name (fill the gaps with the corresponding names). How can I do this in VBA?
    your help greatly appreciated.
    Tissa