|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub zhuanzhi()
Dim i, j, k, m, p, irow
Dim arr, brr
irow = Sheet1.[b65336].End(xlUp).Row
arr = Sheet1.Range("a1:c" & irow)
For i = 3 To irow
If arr(i, 1) = "圆片号" Then
j = j + 1
arr(i, 3) = j
End If
If arr(i - 1, 3) <> "" And arr(i, 3) = "" Then
arr(i, 3) = arr(i - 1, 3)
End If
Next
ReDim brr(1 To 100, 1 To 100)
brr(1, 1) = arr(3, 1)
brr(1, 2) = arr(3, 2)
brr(1, 3) = ""
p = 1
For k = 4 To irow
If arr(k - 1, 3) = arr(k, 3) Then
p = p + 1
brr(p, arr(k, 3) * 3 - 2) = arr(k, 1)
brr(p, arr(k, 3) * 3 - 1) = arr(k, 2)
brr(p, arr(k, 3) * 3) = ""
Else
p = 1
brr(p, arr(k, 3) * 3 - 2) = arr(k, 1)
brr(p, arr(k, 3) * 3 - 1) = arr(k, 2)
brr(p, arr(k, 3) * 3) = ""
End If
Next
Sheet2.[a40].Resize(UBound(brr), UBound(brr, 2)) = brr
End Sub
|
|