- ©«¤l
- 1447
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1471
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-12-5
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-6-13 16:34 ½s¿è
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,¾Ç²ß¤è®×¬° ¤ñ§Ç1©ú²Ó,½Ð¦U¦ì«e½ú«ü±Ð
°õ¦æµ²ªG:
Option Explicit
Sub TEST_2()
Application.DisplayAlerts = False
Dim Brr, Crr, A%, Z, i&, C%, T$, T2$, T3$, T5$, xR As Range, M&
Set Z = CreateObject("Scripting.Dictionary")
Set xR = Range([Á`ªí!F1], [Á`ªí!A65536].End(3)): Brr = xR
ReDim Crr(1 To UBound(Brr), 1 To 200)
For i = 2 To UBound(Brr)
If i = 2 Then C = C + 1: Crr(1, 1) = "N0\¤ñ§Ç1": Crr(2, 1) = 1
T2 = Brr(i, 2): T3 = Brr(i, 3): T5 = Brr(i, 5): T = T3 & "|" & T5
If Z(T) <> "" Then: GoTo i01
If Z(T5) = "" Then
C = C + 1: Z(T5) = C: Crr(1, C) = T5: Crr(2, C) = Brr(i, 4) & "/" & T3
Z(T) = 1: Z(T5 & "|r") = 2: GoTo i01
End If
A = Z(T5 & "|r"): A = A + 1: Crr(A, Z(T5)) = Brr(i, 4) & "/" & T3
Z(T5 & "|r") = A: Z(T) = 1
If M < A Then M = A: Crr(M, 1) = M - 1
i01: Next
If C <= 1 Then MsgBox "µL¸ê®Æ!": Exit Sub
On Error Resume Next
Sheets("¤ñ§Ç1©ú²Ó").Delete
On Error GoTo 0
With Worksheets.Add(after:=Worksheets(Sheets.Count))
.Name = "¤ñ§Ç1©ú²Ó"
With .[A1].Resize(M, C)
.Value = Crr: .EntireColumn.AutoFit
End With
End With
Set Z = Nothing: Set xR = Nothing: Erase Brr, Crr
End Sub
'=====================================
¸É¥R:
¥H¤U¬O¤ñ§Ç2©ú²Ó
°õ¦æµ²ªG:
Sub TEST_3()
Application.DisplayAlerts = False
Dim Brr, Crr, A%, Z, i&, C%, T$, T2$, T3$, T6$, xR As Range, M&
Set Z = CreateObject("Scripting.Dictionary")
Set xR = Range([Á`ªí!F1], [Á`ªí!A65536].End(3)): Brr = xR
ReDim Crr(1 To UBound(Brr), 1 To 200)
For i = 2 To UBound(Brr)
If i = 2 Then C = C + 1: Crr(1, 1) = "N0\¤ñ§Ç1": Crr(2, 1) = 1
T2 = Brr(i, 2): T3 = Brr(i, 3): T6 = Brr(i, 6): T = T3 & "|" & T6
If Z(T) <> "" Then: GoTo i01
If Z(T6) = "" Then
C = C + 1: Z(T6) = C: Crr(1, C) = T6: Crr(2, C) = Brr(i, 4) & "/" & T3
Z(T) = 1: Z(T6 & "|r") = 2: GoTo i01
End If
A = Z(T6 & "|r"): A = A + 1: Crr(A, Z(T6)) = Brr(i, 4) & "/" & T3
Z(T6 & "|r") = A: Z(T) = 1
If M < A Then M = A: Crr(M, 1) = M - 1
i01: Next
If C <= 1 Then MsgBox "µL¸ê®Æ!": Exit Sub
On Error Resume Next
Sheets("¤ñ§Ç2©ú²Ó").Delete
On Error GoTo 0
With Worksheets.Add(after:=Worksheets(Sheets.Count))
.Name = "¤ñ§Ç2©ú²Ó"
With .[A1].Resize(M, C)
.Value = Crr: .EntireColumn.AutoFit
End With
End With
Set Z = Nothing: Set xR = Nothing: Erase Brr, Crr
End Sub |
|