簡體   English   中英

VBA宏可自動填充多行

[英]VBA Macro to AutoFill multiple rows

我目前使用此代碼將公式自動填充到最后填充的列:

Dim lngLastColumn As Long

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

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

但是一次只能工作一行。 有沒有辦法將其應用於我選擇的所有行?

謝謝,

托馬斯

您可以嘗試以下方法:

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