- ©«¤l
- 1446
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1470
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-10-21
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-2-8 09:52 ½s¿è
¦^´_ 3# ymes
ÁÂÁ«e½ú¦^´_
קï¤è®×¦p¤U,½Ð«e½ú¸Õ¸Õ¬Ý
¹B°Ê·|¤À²Õªí_20230208.zip (40.87 KB)
°õ¦æ«e:
°õ¦æµ²ªG:
Option Explicit
Sub TEST_1()
Dim Drr, Brr, Crr, Y, ¶Ã¼Æ&, ¤H¼Æ&, ¹D¼Æ&, ²Õ¼Æ&, °õ¦æ¼Æ&, ¶]¹D¼Æ&, i&
Dim ¶µ¥Ø$, Arr(1 To 1000, 1 To 3), n&, m&
¶µ¥Ø = Split(ActiveSheet.Name, "(")(0)
¶]¹D¼Æ = [A3].End(xlDown).Row - 2
Drr = Range([³ø¦Wªí!C2], [³ø¦Wªí!A65536].End(3))
For i = 1 To UBound(Drr)
If Drr(i, 3) Like ¶µ¥Ø & "*" Then
n = n + 1
Arr(n, 1) = Drr(i, 1): Arr(n, 2) = Drr(i, 2): Arr(n, 3) = Drr(i, 3)
End If
If InStr(Cells(i, 1), ¶µ¥Ø) Then Cells(i, 2).Resize(1, 2).ClearContents: m = m + 1
Next
If n = 0 Or m < n Then MsgBox "µLªk°õ¦æ": Exit Sub
[L:N].ClearContents: [L1].Resize(n, 3) = Arr
¤H¼Æ = n: ReDim Brr(¶]¹D¼Æ - 1, 1)
Head:
Set Y = CreateObject("Scripting.Dictionary")
Do While °õ¦æ¼Æ < ¤H¼Æ
Randomize: ¶Ã¼Æ = Rnd() * 10000 Mod ¤H¼Æ + 1
If Y.Exists(¶Ã¼Æ) = Empty Then
°õ¦æ¼Æ = °õ¦æ¼Æ + 1
Y(¶Ã¼Æ) = ""
¹D¼Æ = °õ¦æ¼Æ Mod ¶]¹D¼Æ
Y(Arr(¶Ã¼Æ, 1) & "|" & ¹D¼Æ) = ""
²Õ¼Æ = IIf(¹D¼Æ, °õ¦æ¼Æ \ ¶]¹D¼Æ + 1, °õ¦æ¼Æ \ ¶]¹D¼Æ)
Y(Arr(¶Ã¼Æ, 1) & "/" & ²Õ¼Æ) = ""
Crr = Y(²Õ¼Æ & "/²Õ")
If Not IsArray(Crr) Then
Crr = Brr
End If
¹D¼Æ = IIf(¹D¼Æ, ¹D¼Æ, ¶]¹D¼Æ)
Crr(¹D¼Æ - 1, 0) = Arr(¶Ã¼Æ, 1): Crr(¹D¼Æ - 1, 1) = Arr(¶Ã¼Æ, 2)
Y(²Õ¼Æ & "/²Õ") = Crr
End If
If (Y.Count - ²Õ¼Æ) Mod °õ¦æ¼Æ Then
²Õ¼Æ = 0
°õ¦æ¼Æ = 0
GoTo Head
End If
Loop
For i = 1 To ²Õ¼Æ
[B3].Item((i - 1) * (¶]¹D¼Æ + 3) + 1, 1).Resize(¶]¹D¼Æ, 2) = Y(i & "/²Õ")
Next
End Sub
Sub ²M°£()
Dim ¶µ¥Ø$, i&
¶µ¥Ø = Split(ActiveSheet.Name, "(")(0)
For i = 1 To [³ø¦Wªí!A65536].End(3)
If InStr(Cells(i, 1), ¶µ¥Ø) Then Cells(i, 2).Resize(1, 2).ClearContents
Next
[L:N].ClearContents
End Sub |
|