0

我想将我的数据从不同的行复制到其他列。例子。

B4 has to be copied to H129 ,
B25 to H130,
B46 to H131...and so on ..

这里的行增加了 21 行。

如何在excel中做到这一点?

4

3 回答 3

0

转到 VBA 并:

Sub sdgfsa()

    Dim i As Integer
    Dim j As Integer

    j = 129
    For i = 4 To 1000 Step 21 'put the end number you want, the start is 4 like your example
        Plan1.Cells(j, 8).Value = Plan1.Cells(i, 2).Value 'Here, plan1 represents the sheet, 2 is B column, 8 is H column
        'or you can use KazJaw's Copy here
        j = j + 1 'j gets incremented
    Next
End Sub
于 2013-04-04T16:28:46.903 回答
0

当您需要复制所有内容(即值和格式)时,请以这种方式进行:

Range("B4").Copy Range("H129")

使用@Daniel 代码,您可能在循环中需要这样的东西

'...see Daniel answer for beginning
Plan1.Cells(i, 2).Copy Plan1.Cells(j, 8)
'... and so on
于 2013-04-04T16:30:44.000 回答
0

在单元格 H129 中输入以下公式:

=INDIRECT("b"&(ROW(H129)-129)*21+4)

然后使用“向下填充”将此单元格中的公式复制到其下方的单元格中。

这是因为“H129”引用将在复制时更改为 H130、H131 等,因此 ROW() 函数将连续返回更高的数字。

编辑:

更正了公式以匹配相关示例。

于 2013-04-04T16:49:01.983 回答