標題:
[發問]
要怎麼 加入空白行
[打印本頁]
作者:
smgm1234
時間:
2013-10-5 12:16
標題:
要怎麼 加入空白行
我用vba 合併 SHEETS 多個 SHEETS 程式碼如下 但我想在每個 SHEETS 複製過來的時候 都往下移動5行 (每個SHEETS資料都不一樣多列)
正在努里學習中 謝謝大大們的幫忙
Sub 合併()
Dim b(11) As Integer
Range("a2:z10000").Select
Selection.ClearContents
Cells(1, 1).Select
For j = 2 To 11
b(j) = Sheets(j).UsedRange.Rows.Count
c = Sheets(1).UsedRange.Rows.Count
For i = 1 To b(j) + 1
a1 = Sheets(j).Cells(i + 1, 1).Value
a2 = Sheets(j).Cells(i + 1, 2).Value
a3 = Sheets(j).Cells(i + 1, 3).Value
a4 = Sheets(j).Cells(i + 1, 4).Value
a5 = Sheets(j).Cells(i + 1, 5).Value
a6 = Sheets(j).Cells(i + 1, 6).Value
a7 = Sheets(j).Cells(i + 1, 7).Value
a8 = Sheets(j).Cells(i + 1, 8).Value
Worksheets("總表").Cells(c + i, 1).Value = a1
Worksheets("總表").Cells(c + i, 2).Value = a2
Worksheets("總表").Cells(c + i, 3).Value = a3
Worksheets("總表").Cells(c + i, 4).Value = a4
Worksheets("總表").Cells(c + i, 5).Value = a5
Worksheets("總表").Cells(c + i, 6).Value = a6
Worksheets("總表").Cells(c + i, 7).Value = a7
Worksheets("總表").Cells(c + i, 8).Value = a8
Next i
Next j
Sheets(1).Select
End Sub
作者:
oobird
時間:
2013-10-6 09:24
Sub 合併()
With Sheets("總表")
.UsedRange.Offset(1, 0) = ""
For j = 2 To Sheets.Count
a = Sheets(j).UsedRange.Offset(1, 0)
n = IIf(.Cells(2, 1) = "", 2, .Cells(65536, 1).End(3).Row + 6)
.Cells(n, 1).Resize(UBound(a), UBound(a, 2)) = a
Next
End With
End Sub
複製代碼
作者:
smgm1234
時間:
2013-10-7 12:55
回復
2#
oobird
謝謝大大的教學 萬分感謝:D
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)