在最后使用的行之后插入数据

taz*_*taz 3 excel vba excel-vba

**问题:**我需要在工作表中最后使用的行之后插入数据。我可以使用以下代码找到最后使用的行。

ActiveSheet.Cells.(Rows.count, "D").End(xlUp).row
Run Code Online (Sandbox Code Playgroud)

现在在这里,我必须在最后使用的行旁边插入数据。

小智 5

首先定义lastrow为变量。什么.row确实是返回一个表示该行,在这种情况下,最后一排。的+1由1个细胞移动下来。

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

Activesheet.Cells(lastrow, "D").Value = "Your Value here"
Run Code Online (Sandbox Code Playgroud)