2017-10-19 78 views
1

我想自動填充我的公式到最後一列。這裏是我的代碼:自動填充列直到使用宏的最後一列

Dim LastColumn As Long 
LastColumn = Cells(5, Columns.Count).End(xlToLeft).Column 
Selection.AutoFill Destination:=Range("B1:" & LastColumn & "1"), Type:=xlFillDefault 

我已經成功地通過可變LastColumn計數的最後一列,但自動填充過程中,它失敗了。所以我想從列B開始自動填充列Lastcolumn

請幫忙。我的代碼有什麼問題?

+0

thanks !!有用!! –

回答

2

你有一個號碼LastColumn,所以你不能直接在Range中使用它。用這個代替:

Selection.AutoFill Destination:=Range(Cells(1, 2), Cells(1, LastColumn)), Type:=xlFillDefault 
相關問題