【发布时间】:2018-10-23 22:13:59
【问题描述】:
我将两张表合并为一张,并选择选择列来执行此操作。这些表是员工轮班的时间表。我已将第一张表 (1) 列复制到新表 (3) 中:日期、星期几、时间、显示封面、员工。我现在正在尝试将所需的列从工作表(2)复制到工作表(3)。其中之一是轮班时间。我需要将其添加到现有的时间列中,即第 3 列。目前它正在替换该数据。这是我所拥有的:
Private Sub CommandButton1_Click()
Dim lastrow As Long, erow As Long
lastrow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lastrow
Sheet1.Cells(i, 1).Copy
erow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Sheet1.Paste Destination:=Sheets(3).Cells(erow, 1)
Sheet1.Cells(i, 2).Copy
Sheet1.Paste Destination:=Sheets(3).Cells(erow, 2)
Sheet1.Cells(i, 3).Copy
Sheet1.Paste Destination:=Sheets(3).Cells(erow, 3)
Sheet1.Cells(i, 5).Copy
Sheet1.Paste Destination:=Sheets(3).Cells(erow, 4)
Sheet1.Cells(i, 8).Copy
Sheet1.Paste Destination:=Sheets(3).Cells(erow, 5)
Sheet2.Cells(i, 1).Copy
Sheet2.Paste Destination:=Sheets(3).Cells(erow, 3)
Next i
Application.CutCopyMode = False
Sheet3.Columns.AutoFit
Range("A1").Select
End Sub
【问题讨论】: