我有從列O - > X的公式,並需要它們將它們拖到最後一行使用。下面是當前代碼我使用:VBA拖動公式(多行)到最後一行使用
Dim wkb As Workbook
Dim wkbFrom As Workbook
Dim wks As Worksheet
Dim rng As Range
Dim path As String, FilePart As String
Dim TheFile
Dim loc As String
Dim Lastrow As Long
Set wkb = ThisWorkbook
loc = shPivot.Range("E11").Value
path = shPivot.Range("E12").Value
FilePart = Trim(shPivot.Range("E13").Value)
TheFile = Dir(path & "*" & FilePart & ".xls")
Set wkbFrom = Workbooks.Open(loc & path & TheFile & FilePart)
Set wks = wkbFrom.Sheets("SUPPLIER_01_00028257_KIK CUSTOM")
Set rng = wks.Range("A2:N500")
'Copies range from report generated to share drive and pastes into the current week tab of open order report
rng.Copy wkb.Sheets("Current Week").Range("A4")
With ActiveSheet
Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("O4:X4").AutoFill .Range("O4:X4").Resize(Lastrow)
End With
代碼LASTROW不拖拉公式下推
是否因爲'.Resize(Lastrow)'實際上拼寫了'.Reize(Lastrow)'在代碼的底部? –
是的,我發現了這個錯誤並修復了它。這不是問題。 – kmiao91
嘗試錄製宏並手動執行需要完成的操作,然後修改代碼。 –