【问题标题】:VBA Macro to AutoFill multiple rowsVBA宏自动填充多行
【发布时间】:2018-08-14 22:20:29
【问题描述】:

我目前使用此代码将公式自动填充到最后填充的列:

Dim lngLastColumn As Long

lngLastColumn = Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column

Range(Activecell, Cells(Activecell.Row, lngLastColumn)).FillRight

但它一次只能用于一行。有没有办法将它应用于我选择的所有行?

谢谢,

托马斯

【问题讨论】:

    标签: excel vba


    【解决方案1】:

    你可以试试这个:

    Dim lngLastColumn As Long
    lngLastColumn = Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
    
    Dim cell As Range
    For Each cell In Selection.Columns(1).Cells
        Range(cell, Cells(cell.Row, lngLastColumn)).FillRight
    Next
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-20
      • 1970-01-01
      • 2022-06-25
      • 1970-01-01
      • 1970-01-01
      • 2020-06-10
      相关资源
      最近更新 更多