【发布时间】:2016-08-21 11:16:35
【问题描述】:
我是 VBA 新手,需要一些帮助。
我用
创建了一个新行ActiveCell.Select
Selection.Offset(1).EntireRow.Insert
现在,如何为iRow = 选择新行?
【问题讨论】:
-
你do not need to select。如果您想知道新行的索引,那将在您使用
Insert反对的那一行的正上方。
我是 VBA 新手,需要一些帮助。
我用
创建了一个新行ActiveCell.Select
Selection.Offset(1).EntireRow.Insert
现在,如何为iRow = 选择新行?
【问题讨论】:
Insert 反对的那一行的正上方。
第一件事:永远避免Select/Selection和Activate/ActiveXXX
话虽这么说,但不知道引用 ActiveCell 有何不同,代码如下:
ActiveCell.Offset(1).EntireRow.Insert '<--| insert new line just below currently active cell
然后
irow = ActiveCell.Row + 1 '<--! get the row of the ActiveCell and add 1 to it
【讨论】: