- ©«¤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-11-28
|
¦^´_ 3# PJChen
ÁÂÁ«e½ú¦^´_,¤@°_¾Ç²ß,ÁÂÁ½׾Â,Á¦U¦ì«e½ú
«á¾ÇÂdzo©«½Æ²ß¬Q¤Ñªº¤è®×,¤è®×¤ß±oµù¸Ñ¦p¤U,½Ð«e½ú°Ñ¦Ò,½Ð¦U¦ì«e½ú«ü±Ð
Option Explicit
Sub TEST()
Dim Brr, V, i, j&, Z&, xR As Range
'¡ô«Å§iÅܼÆ:(Brr,V,i)¬O³q¥Î«¬ÅܼÆ,(j,Z)¬Oªø¾ã¼Æ,xR¬OÀx¦s®æÅܼÆ
Set xR = Range([A17], Cells(Rows.Count, "A").End(xlUp)): Brr = xR
'¡ô¥OxR³oÀx¦s®æÅܼƬO [A17]¨ì AÄæ³Ì«á¤@Ó¦³¤º®eÀx¦s®æ,
'¥OBrr³o³q¥Î«¬ÅܼƬO ¤Gºû°}¦C,¥HxRÅܼÆ(Àx¦s®æ)ȱa¤J
With xR.Offset(0, 1)
'¡ô¥H¤U¬OÃö©óxRÅܼƦV¥k°¾²¾¤@Ä檺µ{§Ç
.Value = Brr
'¡ô¥O¨äÀx¦s®æȬO Brr°}¦CÈ
For Each i In Array("*(", ")*", " "): .Replace i, "", 2: Next
'¡ô³]³v¶µ°j°é,¥Oi³o³q¥Î«¬ÅܼƬO ¤@ºû°}¦C¤¤ªº¤@Ó¦r¦ê
'¥O¸Ó½d³òÀx¦s®æ°µ¦r¤¸¸m´«,¥ý±N¥ª¬A©·"(" ¥ªÃ䪺¦r¤¸³£´«¦¨ªÅ¦r¤¸
'¦A±N¥k¬A©·")" ¥kÃ䪺¦r¤¸³£´«¦¨ªÅ¦r¤¸
'³Ì«á±NªÅ¥Õ¦r¤¸³£´«¦¨ªÅ¦r¤¸
For i = 65 To 122: .Replace Chr(i), "", 2: Next
'¡ô³]¶¶°j°é!i±q65 ¨ì122
'¥O¸Ó½d³òÀx¦s®æ°µ¦r¤¸¸m´«±qA,B,C,D....°µ¸m´«¦¨ªÅ¦r¤¸,Chr(65)="A"
', 2¬O«üÀx¦s®æ¸Ì¦r¦ê³¡¤À¬Û¦P´N°µ¸m´«,¤£»Ýn¦r¦ê¥þ³¡¬Û¦P¤~¸m´«
Brr = .Value
'¡ô¥OBrr³o³q¥Î«¬Åܼƴ«¸Ë¤Wz³o¨Ç°j°éªºÀx¦s®æµ²ªGÈ
End With
For i = 1 To UBound(Brr)
'¡ô³]¶¶°j°é!i±q1 ¨ìBrrÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
V = Split(Brr(i, 1), ",")
'¡ô¥OV³o³q¥Î«¬ÅܼƬO¤@ºû°}¦C,¥Hi°j°é¦C1ÄæBrr°}¦CȳQ","¤À³Î«áªºÈ
For j = 0 To UBound(V)
'¡ô³]¶¶°j°é!j±q0 ¨ìV°}¦C³Ì¤j¯Á¤Þ¸¹¼Æ
If InStr(V(j), "-") Then
'¡ô¦pªGj°j°éV°}¦CÈ¥]§t"-"²Å¸¹??
Z = Z + Abs(Evaluate("=" & V(j))) + 1
'¡ô´N¥OZ³oªø¾ã¼ÆÅܼƬO ¦Û¨ + pºâÈ
'pºâÈ:j°j°éV°}¦CȦb«e±¥[Ó"="¤§«á°µ¹Bºâ
'¨Ò¦p:Evaluate("=2-14") =-12
'Abs(-12)=12 :¬Oµ´¹ïÈ,Åýȳ£ÅÜ¥¿¼Æªº·N«ä,
'³Ì«á«ö·Ó½d¨Ò·N¸q +1
ElseIf V(j) <> "" Then
'¡ô§_«h¦pªGj°j°éV°}¦CȤ£¬OªÅ¦r¤¸?
Z = Z + 1
'¡ô´N¥OZÅܼƲ֥[ 1
End If
Next
Brr(i, 1) = Z: Z = 0
'¡ô¥Oi°j°é¦C²Ä1ÄæBrr°}¦CȬO ÅܼÆZ,
'¡ô¥OZÅܼƬO 0 (¦]¬°n¶]iªº¤U¤@Ó°j°é¤F,©Ò¥HnÅýZÂk¹s«ºâ)
Next
xR.Offset(0, 1) = Brr
'¡ô¥OxRÅܼƦV¥k°¾²¾¤@Äæ,³o½d³òÀx¦s®æÈ¥HBrr°}¦Cȱa¤J
Set xR = Nothing: Erase Brr, V
'¡ô¥OÄÀ©ñ³o¨ÇÅܼÆ
End Sub |
|