【问题标题】:Selecting last-1 row and auto filling to last +1 row选择最后 1 行并自动填充到最后 +1 行
【发布时间】:2018-11-22 01:12:47
【问题描述】:

我想选择最后一行之前的行,自动填充到最后一行下面的行。由于某种原因,目标行不喜欢命名范围的格式。这是我收到错误的代码:

Sub Range_Find_Method()

Dim lRow As Long
lRow = Cells.Find(What:="*", _
                After:=Range("A1"), _
                LookAt:=xlPart, _
                LookIn:=xlFormulas, _
                SearchOrder:=xlByRows, _
                SearchDirection:=xlPrevious, _
                MatchCase:=False).Row
Rows(lRow - 1).Select   
    Selection.AutoFill Destination:=Rows(lRow - 1 : lRow + 1), Type:=xlFillDefault


End Sub

【问题讨论】:

    标签: vba excel autofill


    【解决方案1】:

    这是正确的语法:

    Selection.AutoFill Destination:=Rows(lRow - 1 & ":" & lRow + 1), Type:=xlFillDefault
    

    下一步,如果您愿意,请尽量避免使用 SelectSelection - How to avoid using Select in Excel VBA

    【讨论】:

      猜你喜欢
      • 2013-10-05
      • 2021-08-10
      • 1970-01-01
      • 1970-01-01
      • 2020-11-08
      • 1970-01-01
      • 2012-06-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多