|
楼主 |
发表于 2023-4-15 22:55
|
显示全部楼层
Sub 按钮2_Click()
Dim WD As Worksheet
Set WD = ThisWorkbook.Sheets("排列")
Dim a, b, c, d, a1, a2, b1, c1, d1 As Integer
Dim E As Long
Dim arr() As Variant
Dim brr()
arr = WD.Range("AZ3:BG1227").Value
ReDim brr(1 To 1048576, 1 To 5)
E = 0
For a = 1 To 1224
If arr(a, 1) <> "" And arr(a, 2) <> "" Then
a1 = arr(a, 1)
a2 = arr(a, 2)
For b = 1 To 1224
If arr(b, 3) <> "" And arr(b, 4) <> "" Then
If arr(b, 3) = a2 Then
b1 = arr(b, 4)
For c = 1 To 1224
If arr(c, 5) <> "" And arr(c, 6) <> "" Then
If arr(c, 5) = b1 Then
c1 = arr(c, 6)
For d = 1 To 1224
If arr(d, 7) <> "" And arr(d, 8) <> "" Then
If arr(d, 7) = c1 Then
d1 = arr(d, 8)
E = E + 1
brr(E, 1) = a1
brr(E, 2) = a2
brr(E, 3) = b1
brr(E, 4) = c1
brr(E, 5) = d1
End If
End If
Next d
End If
End If
Next c
End If
End If
Next b
End If
Next a
WD.Range("CS3").Resize(E, 5) = brr
Erase arr
Erase brr
ThisWorkbook.RefreshAll
MsgBox ("中奖")
End Sub
我根据以前本论坛前辈给的指教,重新改了一下。成功了且速度较快。
至于转换,一个我没清晰的搞懂其中逻辑。再者转换后回填的无用单元格里都是N/A,使得再次参与计算需要排除。所以我总对转换不友好。
谢谢你的回复,十分感谢!!! |
|