感谢曾经帮助我的老师们!!趁着今年疫情期间学习了一下VBA!自己的问题用VBA来练习一下!
Sub AwTest()
Dim i%, j%, r%, arr, TempAr
arr = [a1].CurrentRegion
TempAr = Array(1, 2, 3, 4, 5, 6, 7, 10, 11)
ReDim brr(1 To UBound(arr) * 3, 1 To UBound(arr, 2) - 2)
For i = 1 To UBound(arr)
r = r + 1
For j = 0 To UBound(TempAr)
brr(r, j + 1) = arr(i, TempAr(j))
Next
If r >= 2 Then
For j = 8 To 9
If Len(arr(i, j)) Then
r = r + 1
brr(r, 5) = arr(i, 5)
brr(r, 7) = arr(i, j)
brr(r, 9) = arr(i, 11)
End If
Next
End If
Next
[a15].Resize(r, UBound(brr, 2)) = brr
End Sub |