|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 组号()
Dim m&, n&, o&, x&, m1&, m2&, m3&, m4&
Dim arr, brr1(), brr2(), brr3(), brr4()
With Sheets("排列")
arr = .Range("CR3:CU" & .[CR1:CU99999].Find("*", , xlValues, , xlByRows, xlPrevious).Row)
For m1 = 1 To UBound(arr)
For m2 = 1 To UBound(arr)
If Right(arr(m1, 1), 2) = Left(arr(m2, 2), 2) Then
m = m + 1
ReDim Preserve brr1(1 To m)
brr1(m) = arr(m1, 1) & Right(arr(m2, 2), 2)
For m3 = 1 To UBound(arr)
If Right(brr1(m), 2) = Left(arr(m3, 3), 2) Then
n = n + 1
ReDim Preserve brr2(1 To n)
brr2(n) = brr1(m) & Right(arr(m3, 3), 2)
For m4 = 1 To UBound(arr)
If Right(brr2(n), 2) = Left(arr(m4, 4), 2) Then
o = o + 1
ReDim Preserve brr3(1 To o)
brr3(o) = brr2(n) & Right(arr(m4, 4), 2)
End If
Next
End If
Next
End If
Next
Next
.Range("Cx3").Resize(UBound(brr3), 1) = Application.Transpose(brr3)
arr = .Range("DP3:DQ" & .[DP1:DQ99999].Find("*", , xlValues, , xlByRows, xlPrevious).Row)
For m4 = 1 To UBound(arr)
If arr(m4, 1) > 0 Then
x = x + 1
ReDim Preserve brr4(1 To 2, 1 To x)
brr4(1, x) = arr(m4, 1)
brr4(2, x) = arr(m4, 2)
End If
Next
.Range("Du3").Resize(UBound(brr4, 2), 2) = Application.Transpose(brr4)
End With
MsgBox ("完毕")
End Sub |
|