源数据
结果
Sub 转置()
Dim arr, brr(1 To 60000, 1 To 4)'设置一个足够大的数组brr
arr = [a1].CurrentRegion'源数据赋值到数组arr
For j = 2 To UBound(arr, 2)'遍历数组arr,按列遍历
For i = 3 To UBound(arr)
k = k + 1'计数
'当k=1时
brr(k, 1) = arr(i, 1) '一、人工成本
brr(k, 2) = arr(1, j) '大场
brr(k, 3) = arr(2, j) '预算数
brr(k, 4) = arr(i, j) '数值
Next
Next
[e26].Resize(k, 4) = brr
End Sub