vba 在最后使用的行之后插入数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30478923/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Insert data after last used row
提问by taz
**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.
现在我必须在最后使用的行旁边插入数据。
回答by iMan7
Define lastrowas a variable first.
What .rowdoes is returns a number indicating the row, in this case the last row. The +1moves it down by 1 cell.
首先定义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"

