I am trying to copy columns from Sheet 1 and paste them in Sheet 2, particularly in the next empty column on sheet 2 (so that I don't overwrite data). In total, I need to copy columns 3-81.
我正在尝试从表1复制列并将它们粘贴到表2中,特别是在表2的下一个空列中(这样我就不会覆盖数据)。总之,我需要复制列3-81。
Here is the code I have so far:
下面是我到目前为止的代码:
Dim col As Integer
For i = 3 To 81
Worksheets("Sheet1").Columns(i).Copy Destination:=Sheets("Sheet 2").Column(i).
Since I apply a function to every pasted column before copying and pasting the next one, I cannot simply denote the destination as column (i) because it will simply overwrite that last column of calculated data.
由于在复制和粘贴下一列之前,我对每个已粘贴的列都应用了一个函数,因此不能简单地将目标表示为列(I),因为它只会覆盖计算数据的最后一列。
How can I change the destination so that I do not have this problem?
我怎样才能改变目的地,这样我就不会有这个问题?
This question has been asked many times before however I cannot find my solution since I seem to be the only one using a loop and assigning col as i.
这个问题以前被问过很多次,但是我找不到我的解决方案,因为我似乎是唯一一个使用循环并将col赋值为I的人。
1 个解决方案
#1
1
Dim i As Long, j As Long
j = 3
For i = 3 To 81
Worksheets("Sheet1").Columns(i).Copy _
Destination:=Sheets("Sheet 2").Columns(j)
j = j + 2
Next i
#1
1
Dim i As Long, j As Long
j = 3
For i = 3 To 81
Worksheets("Sheet1").Columns(i).Copy _
Destination:=Sheets("Sheet 2").Columns(j)
j = j + 2
Next i