- ©«¤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-11-29
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-11-9 09:20 ½s¿è
¦^´_ 7# ã´£³¡ªL
ÁÂÁ½׾Â,ÁÂÁ«e½ú«ü¾É
«á¾ÇÂǦ¹©«¾Ç²ß«e½úªº¤è®×,°õ¦æµ²ªG»P¤ß±oµù¸Ñ¦p¤U,½Ð«e½ú¦A«ü¾É
°õ¦æ«e:
°õ¦æµ²ªG:
Sub «¾ã()
Dim Arr, Brr, A, B, xD, i&, N&, j%, T$
'¡ô«Å§iÅܼÆ:(Arr,Brr,A,B,xD)¬O³q¥Î«¬ÅܼÆ,(i,N)¬Oªø¾ã¼Æ,j¬Oµu¾ã¼Æ,T¬O¦r¦êÅܼÆ
[I2:L6000].Clear
'¡ô¥O[I2:L6000]³o½d³òÀx¦s®æ²M°£
Set xD = CreateObject("Scripting.Dictionary")
'¡ô¥OxD³o³q¥Î«¬ÅܼƬO ¦r¨å
Arr = Range([G2], [F65536].End(xlUp))
'¡ô¥OArr³o³q¥Î«¬ÅܼƬO¤Gºû°}¦C,¥H[G2]¨ìFÄæ³Ì«á¦³¤º®eÀx¦s®æȱa¤J°}¦C¤¤
For i = 1 To UBound(Arr)
'¡ô³]¶¶°j°é!¥Oi±q1 ¨ìArr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
xD(Arr(i, 1) & "") = Arr(i, 2)
'¡ô¥Oi°j°é¦C1ÄæArr°}¦CÈ(¦r¦ê)·íkey,
'item¬O i°j°é¦C1ÄæArr°}¦CÈ,¯Ç¤JxD¦r¨å¤¤
Next i
Arr = Range([C2], [A65536].End(xlUp))
'¡ô¥OArr°}¦C´«¸Ë²± [C2]¨ìAÄæ³Ì«á¦³¤º®eÀx¦s®æ È
ReDim Brr(1 To 20000, 1 To 4)
'¡ô«Å§iBrrªÅ°}¦Cªº½d³ò,Áa¦V¯Á¤Þ¸¹1~20000,¾î¦V1~4
For i = 1 To UBound(Arr)
'¡ô³]¶¶°j°é!¥Oi±q1 ¨ìArr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
A = Split(Replace(Arr(i, 2), ChrW(160), ""), "¡B")
'¡ô¥OA³o³q¥Î«¬ÅܼƬO ¤@ºû°}¦C:
'i°j°é¦C2ÄæArr°}¦Cȸg¦Ü´«¦r¤¸(ªÅ®æ>>ªÅ¦r¤¸)¦¨ªº·s¦r¦ê,¦A¥H"¡B"¤À³Î¦¨ªº°}¦C
https://learn.microsoft.com/zh-t ... haracter-set-128255
B = Split(Replace(Arr(i, 3), ChrW(160), ""), "¡B")
'¡ô¥OB³o³q¥Î«¬ÅܼƬO ¤@ºû°}¦C:
'i°j°é¦C3ÄæArr°}¦Cȸg¦Ü´«¦r¤¸(ªÅ®æ>>ªÅ¦r¤¸)¦¨ªº·s¦r¦ê,¦A¥H"¡B"¤À³Î¦¨ªº°}¦C
If UBound(A) <> UBound(B) Then MsgBox "²Ä " & i + 1 & " ¦æ¼Æ¾Ú¦³°ÝÃD!! ": Exit Sub
'¡ô¦pªGA°}¦C³Ì¤j¯Á¤Þ¸¹»P ¦pªGB°}¦C³Ì¤j¯Á¤Þ¸¹¤£¦P?
'true´N¸õ¥X´£¥Üµ¡~~~:µ²§ôµ{¦¡°õ¦æ
For j = 0 To UBound(A)
'¡ô³]¶¶°j°é!¥Oj±q1 ¨ìA°}¦C³Ì¤j¯Á¤Þ¸¹
N = N + 1: T = T & "¡B" & xD(B(j) & "")
'¡ô¥ON³oªø¾ã¼ÆÅܼƲ֥[1
'¡ô¥OT³o¦r¦êÅܼƬO ¦Û¨³s±µ "¡B" ¦A³s±µ(¥Hj°j°éB°}¦CȦr¦ê¬dxD¦r¨å¦^¶ÇÈ)
Brr(N, 1) = Arr(i, 1): Brr(N, 2) = A(j)
'¡ô¥ONÅܼƦC1ÄæBrr°}¦CȬO i°j°é¦C1ÄæArr°}¦CÈ
'¡ô¥ONÅܼƦC2ÄæBrr°}¦CȬO j°j°éA°}¦CÈ
Brr(N, 3) = B(j): Brr(N, 4) = xD(B(j) & "")
'¡ô¥ONÅܼƦC3ÄæBrr°}¦CȬO j°j°éB°}¦CÈ
'¡ô¥ONÅܼƦC4ÄæBrr°}¦CȬO ¥Hj°j°éB°}¦CȦr¦ê¬dxD¦r¨å¦^¶ÇÈ
Next j
Arr(i, 1) = Mid(T, 2): T = ""
'¡ô¥Oi°j°é¦C1ÄæArr°}¦CȬO TÅܼƥh°£²Ä1Ó¦r¤¸ªº·s¦r¦ê
'¥OTÅܼƦr¦ê²MªÅ
Next i
With [I2].Resize(N, 4)
'¡ô¥H¤U¬OÃö©ó[I2]ÂX®i¦V¤UNÅܼƦC,ÂX®i¦V¥k4ÄæÀx¦s®æ½d³òªºµ{§Ç
.Columns(2).NumberFormatLocal = "#,##0 ;-#,##0 "
'¡ô¥O³o½d³òÀx¦s®æ²Ä2Äæ®æ¦¡nÅã¥Ü¤d¤À¦ì²Å¸¹(,)
.Columns(3).HorizontalAlignment = xlCenter
'¡ô¥O³o½d³òÀx¦s®æ²Ä3ÄæÀx¦s®æÈ ¤ô¥¹ï»ô¤è¦¡¸m¤¤
.Columns(4).NumberFormatLocal = "@"
'¡ô¥O³o½d³òÀx¦s®æ²Ä4Äæ®æ¦¡¬O¤å¦r
.Borders.LineStyle = 1: .Font.Size = 10
'¡ô¥O³o½d³òÀx¦s®æ®Ø½u¬O²Ó¹ê½u
'¡ô¥O³o½d³òÀx¦s®æ¤å¦r¤j¤p¬°10
.Value = Brr
'¡ô¥O³o½d³òÀx¦s®æÈ¥HBrr°}¦Cȱa¤J
End With
[D2].Resize(UBound(Arr)) = Arr '¶ñ¤JDÄæ¹ïÀ³È
'¡ô¥O[D2]ÂX®i¦V¤U(Arr°}¦C³Ì¤j¯Á¤Þ¸¹¼Æ¦C)Àx¦s®æ½d³ò¥HArr°}¦Cȱa¤J
End Sub |
|