|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub zh()
Dim sh As Worksheet, ar, br(), i&, k&, m&, s$
Set sh = ThisWorkbook.Sheets("费用总表")
ar = sh.Range("a1").CurrentRegion
For i = 3 To UBound(ar)
s = ar(i, 1)
If s <> "" Then
For k = 3 To UBound(ar, 2)
m = m + 1
ReDim Preserve br(1 To 5, 1 To m)
br(1, m) = s
br(2, m) = ar(i, 2)
br(3, m) = ar(1, k)
br(4, m) = ar(2, k)
br(5, m) = ar(i, k)
Next
End If
Next
If m > 0 Then
Set sh = ThisWorkbook.Sheets("转换")
Application.ScreenUpdating = False
With sh
.Cells.Delete shift:=xlUp
.[a1].Resize(, 5) = Array("费用类别", "细分类别", "公司", "年度", "金额")
.[a2].Resize(m, 5) = Application.Transpose(br)
.UsedRange.HorizontalAlignment = xlCenter
.UsedRange.VerticalAlignment = xlCenter
.UsedRange.EntireColumn.AutoFit
End With
Application.ScreenUpdating = True
End If
End Sub
|
|