0
我的腳本從多張工作表中獲取數據並創建一個新的電子表格。我遇到的問題是如何追加到列的末尾。我嘗試這樣做:如何將數據追加到循環中的列
LastRow = Sheets("Test").Cells(Rows.Count, "A").End(xlUp).Row
凡LASTROW被定義爲長,但我遇到了,當我繼續環繞來繞去的錯誤。以下是我迄今爲止:
Sub autoFill()
Dim wb As Workbook, ws As Worksheet
Dim LastRow As Long
Dim Unit As String
Dim ddg As Variant, i As Variant
Set wb = ActiveWorkbook
Set ws = wb.Worksheets("Mapping")
ddg = ws.Range("F4:F21").Value
For Each i In ddg
Unit = "Unit #" & i
LastRow = Sheets("Test").Cells(Rows.Count, "A").End(xlUp).Row
Sheets(Unit).Range("A2:A100").Copy Destination:=Sheets("Test").Range("A1" & LastRow)
Sheets(Unit).Range("B2:B100").Copy Destination:=Sheets("Test").Range("B1" & LastRow)
Next i
End Sub
這工作,太感謝你了! – kdean693