我在电子表格的列中有一列47个数字。在另一张表中,我希望将数字转换成一行。我使用此代码
Worksheets.Add(Before:=Worksheets(1)).Name = "Calc"
Dim k As Integer
For k = 1 To 47
Worksheets("Calc").Cells(1, k).Value = Worksheets("Reformulering").Cells(k + 1, 2).Value
Next k
但是,我希望在下一个数字到来之前,每行重复12次。谁能想到一种方法来做到这一点?
最佳,
ID
答案 0 :(得分:0)
是的,添加另一个从1直到12的循环,如下所示:
Worksheets.Add(Before:=Worksheets(1)).Name = "Calc"
Dim k As Integer
Dim i As Integer
For k = 1 To 47
For i = 1 To 12
Worksheets("Calc").Cells(1, ((k - 1) * 12) + i).Value = Worksheets("Reformulering").Cells(k + 1, 2).Value
Next i
Next k
答案 1 :(得分:0)
您可以无需转置转置值
[Calc!A1:L47] = Application.Transpose([Reformulering!B2:AV2])
与复制范围类似,选择Calc!A1:L1
,Paste Special...
,选中转置,然后确定