|
Sub 转置()
Application.ScreenUpdating = False
Dim ar As Variant
Dim br()
With Sheets("Sheet1")
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "数据源为空!": End
ar = .Range("a1:c" & r)
End With
ReDim br(1 To UBound(ar) * 2, 1 To 10)
ReDim cr(1 To UBound(ar) * 2, 1 To 10)
For i = 2 To UBound(ar) Step 10
m = m + 1
n = n + 2
y = 0
k = k + 1
For s = i To i + 9
If s <= UBound(ar) Then
y = y + 1
br(n - 1, y) = ar(s, 1)
br(n, y) = ar(s, 3)
cr(k, y) = ar(s, 1) & "-" & ar(s, 3)
End If
Next s
If m Mod 3 = 0 Then n = n + 1
If m Mod 6 = 0 Then k = k + 1
Next i
With Sheets("效果一")
.UsedRange = Empty
.[a1].Resize(n, UBound(br, 2)) = br
End With
With Sheets("效果二")
.UsedRange = Empty
.[a1].Resize(k, UBound(cr, 2)) = cr
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
评分
-
1
查看全部评分
-
|