用For / Next 執行 sh3 複製到 sh4 , 若有500列的資料複製需要10秒,
是否有較快速的寫法,避免將來資料超過數千筆,要花上好幾分鐘才能跑完.
Set sh3 = Sheets("Source")
Set sh2 = Sheets("Target")
Application.ScreenUpdating = False ' 關閉螢幕更新
FinalRow = sh3.Range("A" & Rows.Count).End(xlUp).Row '計算原始SHEET有多少ROW
sh2.[A4:Z1000].Delete Shift:=xlToLeft '清除Sh2(Target)
For i = 2 To FinalRow
sh3.Cells(i, 28).Copy sh2.Cells(i + 2, 1) '前面數字=來源檔的列
sh3.Cells(i, 10).Copy sh2.Cells(i + 2, 2) '後面數字=目的檔的列
sh3.Cells(i, 7).Copy sh2.Cells(i + 2, 3)
sh3.Cells(i, 26).Copy sh2.Cells(i + 2, 4)
sh3.Cells(i, 5).Copy sh2.Cells(i + 2, 6)
sh3.Cells(i, 13).Copy sh2.Cells(i + 2, 7)
sh3.Cells(i, 2).Copy sh2.Cells(i + 2, 8)
sh3.Cells(i, 21).Copy sh2.Cells(i + 2, 9)
sh3.Cells(i, 24).Copy sh2.Cells(i + 2, 10)
sh3.Cells(i, 19).Copy sh2.Cells(i + 2, 14)
Next
謝謝 |