Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert data after last used row

Tags:

excel

vba

**Problem:**I need insert the data after last used row in the worksheet. I was able to find last used row with the following code.

ActiveSheet.Cells.(Rows.count, "D").End(xlUp).row

Now here I have to insert data next to the last used row.

like image 411
taz Avatar asked Oct 17 '25 01:10

taz


1 Answers

Define lastrow as a variable first. What .row does is returns a number indicating the row, in this case the last row. The +1 moves it down by 1 cell.

Dim lastrow as Long
lastrow = Activesheet.Cells(Rows.Count, "D").End(xlUp).row + 1

Activesheet.Cells(lastrow, "D").Value = "Your Value here"
like image 52
iMan7 Avatar answered Oct 20 '25 00:10

iMan7



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!