作业帮 > 综合 > 作业

excel 能不能将一列数平均分成四列 比如:一列100行,分成四列25行?

来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:综合作业 时间:2024/05/31 10:02:38
excel 能不能将一列数平均分成四列 比如:一列100行,分成四列25行?
excel 能不能将一列数平均分成四列 比如:一列100行,分成四列25行?
用VBA可以实现.
如果要平均分的列为A列的,如下宏
Sub 一列变四列()
Dim val
Dim intCol As Integer
Dim intRow As Integer
Dim s As Integer
Dim i,j As Integer
s = 0
'
With Sheets("Sheet1")
intRow = .[a65536].End(xlUp).Row '行数
val = Int(intRow / 4)
For i = 1 To 4
For j = 1 To val
s = s + 1
.Cells(j,1 + i) = .Cells(s,1)
Next j
Next i
.Cells(j,i) = .Cells(s + 1,1)
End With
End Su