简体   繁体   English

VBA宏可自动填充多行

[英]VBA Macro to AutoFill multiple rows

I currently use this code to autofill formulas to the last filled column: 我目前使用此代码将公式自动填充到最后填充的列:

Dim lngLastColumn As Long

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

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

But it only works for one row at a time. 但是一次只能工作一行。 Is there a way to apply it to all the rows I've selected? 有没有办法将其应用于我选择的所有行?

Thanks, 谢谢,

Thomas 托马斯

you may try this: 您可以尝试以下方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM