0
此代碼給我錯誤1004和自動填充方法錯誤正確填寫方法如果我刪除第一自動填充方法,然後第二個自動填充工作正常,否則它給出了一個錯誤,我無法使用自動在我的VBA代碼
Sub w()
Set ws1 = ActiveSheet
ws1.Columns("A:A").Insert Shift:=xlToRight, _
CopyOrigin:=xlFormatFromLeftOrAbove
ws1.Range("A1").Value = "S.No"
ws1.Range("A1").Interior.Color = RGB(204, 204, 204)
LastRow = ws1.Cells(Rows.Count, "B").End(xlUp).Row
ws1.Range("A2").Select ws1.Range("A2").FormulaR1C1 = _
"=TEXT(RC[1],""000000000000"")&""-""&TEXT(RC[2],""0000"")"
ws1.Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A" & LastRow), Type:=xlFillDefault
ws1.Range("A2:A" & LastRow).Select
Set ws2 = Workbooks("Closing Asset Listing-Leading Ledger_Aug-17.xlsx").Worksheets(1)
LastRowclosing = ws2.Cells(Rows.Count, "B").End(xlUp).Row
ws2.Columns("A:A").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
ws2.Range("A2").FormulaR1C1 = _
"=TEXT(RC[6],""000000000000"")&""-""&TEXT(RC[7],""0000"")"
ws2.Range("A2").AutoFill Destination:=Range("A2:A" & LastRowclosing), Type:=xlFillDefault
Range("A2:A" & LastRowclosing).Select
ws1.Range("AB2").Select
ws1.Range("AB2").FormulaR1C1 = _
"=VLOOKUP(RC[-27],'[Closing Asset Listing-Leading Ledger_Aug-17.xlsx]Sheet1'!R2C1:R13C12,12,0)"
ws1.Range("AB2").AutoFill Destination:=Range("L2:L" & LastRow), Type:=xlFillDefault
Range("AB2" & LastRow).Select
End Sub
謝謝,羅裏它的工作原理,但我的第三個自動填充的方法去修改之後仍然失敗,請與也 –
幫助,也表明VLOOKUP更新用,如果我想我的表範圍,直到最後一行與數據。 –
您不能從AB2自動填充到列L.您可能只需使用VLOOKUP的整個列。 – Rory