- ©«¤l
- 1440
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1464
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-9-30
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-12-26 08:36 ½s¿è
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,¾Ç²ß¤è®×¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
°õ¦æ«e:
°õ¦æµ²ªG:
Option Explicit
Sub TEST()
Dim ¸ê®Æ°}¦C, ªÅ°}¦C, ¦r¨å, ¥N¸¹$, i&, j%, µ²ªG¦C¸¹&, µ²ªGÄ渹%, µ²ªGÄæ¼Æ%, ³Ì¤j¦C¼Æ%, ¤uµ{§O$, ÃöÁä¦r$
Set ¦r¨å = CreateObject("Scripting.Dictionary")
ÃöÁä¦r = Left([B2], 4)
¸ê®Æ°}¦C = Range([F3], [B65536].End(3)(2, 0))
ReDim ªÅ°}¦C(1 To 1000, 1 To 100)
For i = 1 To UBound(¸ê®Æ°}¦C) - 1
If InStr(¸ê®Æ°}¦C(i, 1), ÃöÁä¦r) = 0 Then GoTo i01
µ²ªGÄ渹 = IIf(¤uµ{§O <> ¸ê®Æ°}¦C(i, 1), µ²ªGÄ渹 + 1, µ²ªGÄ渹)
¦r¨å(i) = µ²ªGÄ渹
¤uµ{§O = ¸ê®Æ°}¦C(i, 1)
¦r¨å(µ²ªGÄ渹 & "/r") = 1
ªÅ°}¦C(1, µ²ªGÄ渹) = Split(¸ê®Æ°}¦C(i, 1), " ")(0)
¸ê®Æ°}¦C(i + 1, 1) = IIf(¸ê®Æ°}¦C(i + 1, 1) = "", ¸ê®Æ°}¦C(i, 1), ¸ê®Æ°}¦C(i + 1, 1))
i01: Next
µ²ªGÄæ¼Æ = µ²ªGÄ渹
For j = 2 To UBound(¸ê®Æ°}¦C, 2)
For i = 1 To UBound(¸ê®Æ°}¦C)
¥N¸¹ = Split(¸ê®Æ°}¦C(i, j) & " ", " ")(1)
If Not ¥N¸¹ Like "[A-Z][A-Z]####*" Or ¦r¨å(i) = 0 Then GoTo i02
µ²ªGÄ渹 = ¦r¨å(i)
µ²ªG¦C¸¹ = ¦r¨å(µ²ªGÄ渹 & "/r")
µ²ªG¦C¸¹ = µ²ªG¦C¸¹ + 1: ¦r¨å(µ²ªGÄ渹 & "/r") = µ²ªG¦C¸¹
ªÅ°}¦C(µ²ªG¦C¸¹, ¦r¨å(i)) = Left(¥N¸¹, 6)
If ³Ì¤j¦C¼Æ < µ²ªG¦C¸¹ Then ³Ì¤j¦C¼Æ = µ²ªG¦C¸¹
i02: Next
Next
With [H2]
.CurrentRegion.ClearContents
.Resize(³Ì¤j¦C¼Æ, µ²ªGÄæ¼Æ) = ªÅ°}¦C
End With
End Sub |
|