我在Column上有500个值。我想将其分为5列,每列100个值。
Sample Input
1
2
3
4
...
50
输出:
Column 1
1...100
Column 2
101..200
column 3
201..300
column 4
301..400
column 5
401..500
Excel或R中是否有任何方法可以简化此操作?我的文件格式是csv。
答案 0 :(得分:0)
假设您的输入数据在列A
中,并且输出从列B
开始,请尝试以下宏。将其分配给按钮有多种用途。
Sub SplitInto100CellsPerColumn()
Dim X As Long, LastRow As Long, vArrIn As Variant, vArrOut As Variant
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
vArrIn = Range("A1:A" & LastRow)
ReDim vArrOut(1 To 100, 1 To Int(LastRow / 100) + 1)
For X = 0 To LastRow - 1
vArrOut(1 + (X Mod 100), 1 + Int(X / 100)) = vArrIn(X + 1, 1)
Next
Range("B1").Resize(100, UBound(vArrOut, 2)) = vArrOut
End Sub
答案 1 :(得分:0)