- ©«¤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 ©ó 2022-11-10 08:17 ½s¿è
¦^´_ 21# ã´£³¡ªL
'ÁÂÁ«e½ú
'³o©«¾Ç¨ì«Ü¦hª¾ÃÑ
'1.=HYPERLINK(), =HYPERLINK(""#xx"",""yy"")==HYPERLINK(""#¤u§@ªí1!xx"",""yy"")
'2.§ó»{ÃÑ ¦r¦êÅܼƸ̫O¯d Âù¤Þ¸¹" ³o¦r¤¸
'3."[^A-Za-z\'-]" ¥¿«h¤å¦r³W«h---«O¯d"^¤å¦r" + "³æ¤Þ¸¹" + "-"
'4.ºë½TªºÀx¦s®æ¦ì¸m±a¤J°}¦CÈ
°õ¦æ«e:
°õ¦æµ²ªG:
Sub TEST_A1()
Dim Arr, Brr, xD, B, i&, j%, Fx$, CT$, T$, T1$, R&, C%, Cx%
'¡ô«Å§iÅܼÆ
Set xD = CreateObject("Scripting.Dictionary")
'¡ô¥O xD¬O¦r¨å
Call ²M°£ '²M°£E¦C¥k¤è¤º®e
'¡ô°õ¦æ Sub ²M°£() °Æµ{¦¡
Arr = Range([h1], [h65536].End(xlUp)).Resize(, 200)
'¡ô¥OArr¬O°}¦C!ˤJ[H1]¨ìHÄæ³Ì«á¤@Ó¦³¤º®eÀx¦s®æ¦A©¹¥kÂX®i200Äæ(¨ì¤FGYÄæ)
For i = 2 To UBound(Arr)
'¡ô³]¶¶°j°é!±q2 ¨ìArr°}¦CÁa¦V³Ì«á¦C¸¹
T = LCase(Trim(Arr(i, 1)))
'¡ô¥ý±NArr°}¦Cªº²Ä¤@Äæ°j°é¦C¥h°£«e«áªÅ®æ«á,
'¦A§â³Ñ¤Uªº¦r¦ê¸Ìªº^¤å¦r¥ÀÂà¤p¼g
If T <> "" Then xD(T) = i
'¡ô¦pªGT¦r¦ê¤£¬OªÅªº!´N±NT¦r¦ê·íkey(Áä)¯Ç¤J¦r¨å, item¬O°j°é¼Æ¤]¬O(¤u§@ªíªº¦C¸¹) '@@
'T¤]¬O«á±µ{§Çn¥ÎªºÃöÁä¦r
Next i
Fx = "=HYPERLINK(""#xx"",""yy"")" '¶W³sµ²¤½¦¡¦@¥Î¦r¦ê--xx´À´«¬°¦ì§}--yy´À´«¬°nÅã¥Ü¤å¦r
'¡ô¥OFx¦r¦ê¬O "=HYPERLINK("#xx","yy")"
'¡ôÂǦ¹©«¾Ç²ß¦p¦óÅý¦r¦êÅܼƸ̫O¯d Âù¤Þ¸¹" ³o¦r¤¸!
'¬ã¨sµ²ªG:¥ý±q¸Ó¦æµ{¦¡½XÀY§À¦U¥h°£±¼¤@Ó " ,¥H¤U¬O²Ó¸`
'1.³Ñ¤Uªº¦r¤¸ =HYPERLINK(""#xx"",""yy""),³sÄòªº""·|«O¯d¤@Ó",¦¨¬°ÅܼƸ̪º"¦r¤¸!
' ¦¨¬° =HYPERLINK("#xx","yy")
'2.nª`·N¦pªG¤À°t¨ì³Ì«á³Ñ¤U¤@Ó"¦r¤¸ ,¬O¤£¤¹³\ªº!
' ¨Ò¦p MsgBox "1""¬O¿ùªº!¦ý¬OVBA·|À°¸É1Ó",Åܦ¨ MsgBox "1""" (¥h°£ÀY§À",³Ñ1"",³Ì«áÅã¥Ü1")
'3.«DÂù¤Þ¸¹¦r¤¸¤§¶¡¤À°t¶¡¹j³Ñ¤U¤@Ó"¦r¤¸,¤]¬O¤£¤¹³\ªº!
' ¨Ò¦pMsgBox "1"2"¬O¿ùªº! (¥h°£ÀY§À",³Ñ1"2,¥u³Ñ¤¤¶¡¤@Ó",·|¥X²{½sĶ¿ù»~°T®§),
' MsgBox "1"2""¤]¬O¿ùªº! §ï¬° MsgBox "12""" °T®§µ¡ 12",§ï¬° MsgBox "1""2" °T®§µ¡ 1"2
'4.MsgBox """1""2""3""4" ,°T®§µ¡ "1"2"3"4
CT = "[^A-Za-z\'-]" '¤å¦r³W«h---«O¯d"^¤å¦r" + "³æ¤Þ¸¹" + "-"
'¡ô¥OCT ¬O¦r¦ê "[^A-Za-z\'-]" ,
'¦p¦óÅý¦r¦êÅܼƸ̫O¯d ³æ¤Þ¸¹' ³o¦r¤¸?? ¦r¦êªºÀY§À¦³Âù¤Þ¸¹¥]§¨¦í´N¥i¥H
Brr = Range([b1], [a65536].End(xlUp))
'¡ô¥OArr¬O°}¦C!ˤJ[B1]»PAÄ榳¤º®eÀx¦s®æ¶¡ ÂX®i¬°³Ì¤p¤è¥¿°Ï°ìÀx¦s®æªºÈ
For i = 2 To UBound(Brr)
'¡ô³]¥~¶¶°j°é!±q 2¨ìBrr°}¦CÁa¦V³Ì«á¦C¸¹
T = Trim(¥¿«hÂà´«(LCase(Brr(i, 2)), " ", CT))
'¡ô±N¤å¦rÂà¤p¼g,¨Ã¥H¥¿«h±N¤£nªº¤å¦r´À´«ªÅ®æ«á¶Ç¦^
'¥OT¬OBrr°}¦C¸Ì²Ä¤GÄæ°j°é¦Cªº³Q³B²z¹LªºÈ! ¦p¦ó³B²z??
'¥ý±NìȦr¦êÂà´«¬°¤p¼g°µ¬° ¥¿«hÂà´«()¦Ûq¸q¨ç¼Æªº³Q¥¿«h¦r¦ê,¨ú¥N¤å¦r¬OªÅ¥Õ¦r¤¸,
'³W«h¦r²Å¬O CT = "[^A-Za-z\'-]"
'¥¿«h¤§«á¦A¥h±¼¦r¦êÀY§ÀªºªÅ¥Õ¦r¤¸
For Each B In Split(T, " ") '¥HªÅ®æ¤À©î³æ¦r
'¡ô³]¤º¶¶°j°é!¥O B ¬O ¤@ºû°}¦C¸Ìªº¤@û!
'þ¨Óªº¤@ºû°}¦C? ¥¿«h¤§«áªº¦r¦ê¥Î ªÅ¥Õ¦r¤¸¤À³Î´N¬O¤@ºû°}¦C
R = xD(B & "")
'¡ô¥OBÅܦ¨¦r¦ê«á·íkey(Áä)!¬d¦r¨å¸Ìªºitem¬O¤°»ò? ¥áµ¹R ªø¾ã¼Æ¸ËµÛ!
'¦pªG¤£¬Oªì©lÈ 0 ´N¬Oªø¾ã¼Æ(¤u§@ªíªº¦C¸¹) '¦b«e±@@¼Ðµù¦ì¸m
If R = 0 Then GoTo b01
'¡ô¦pªG R=0, ªí¥Ü¤£¬OÃöÁä¦r©ÎªÅ®æ. ²¤¹L! ´N¸õ¨ì b01ªº¦ì¸mÄ~Äò°õ¦æ
T1 = B & "|" & i
'¡ô¥OT1¦r¦ê¬O B¦r¦ê & "|" & ¥~°j°é¼Æªº²Õ¦X¦r¦ê(¥H¤UºÙB|i²Õ¦X¦r¦ê)!
'ÃöÁä¦r+i¦C¸¹...¥Î¤_±Æ°£¦P¤@¦C¦r¦ê¥X²{¬Û¦PÃöÁä¦r¤@¦¸¥H¤W
xD(T1) = xD(T1) + 1
'¡ô¥O B|i²Õ¦X¦r¦ê ·íkey ,item²Ö¥[ 1
If xD(T1) > 1 Then GoTo b01
'¡ô¦P¤@¦r¦ê¥X²{1¦¸¥H¤W, ¤£¦A³B²z, ²¤¹L! ´N¸õ¨ì b01ªº¦ì¸mÄ~Äò°õ¦æ
Arr(R, 2) = Arr(R, 2) + 1
'¡ô¥OArr°}¦Cªº²Ä¤GÄæ(ÃöÁä¦r©Ò¦bªº¦C)¦ì¸m²Ö¥[ 1
C = Arr(R, 2)
'¡ô¥OC¬O ¦¸¼Æ²Öp
Arr(R, C + 2) = Replace(Replace(Fx, "xx", "A" & i), "yy", Brr(i, 1))
'¡ô¥Ñ¥ª¦Ó¥k¶ñ¤J"ÃD¸¹"...´À¥N¦¨¶W³s¤½¦¡
'Arr°}¦C¸ÌÃöÁä¦r©Ò¦bªº¦C¸¹(¦¸¼Æ²Öp+2Äæ)ªº¦ì¸m¶ñ¤J Fx³Q³B²z¹Lªº¦r¦ê
'Fx«ç»ò³Q³B²z?? Fx³oÅܼƦb«e¤è¦´N³Q©w¸q¬°©T©wÅÜ¼Æ "=HYPERLINK("#xx","yy")"
'¦b¦¹³B¥u¬O¨CӲŦX§PÂ_¦¡ªº°j°é,®³¥¦¥X¨ÓÅܬ°·Qnªº¶W³sµ²¤½¦¡ªº¤å¦r¦ê
'¦]¬°¦¹¤å¦r¦êªº«e¤è = ¦b Arr°}¦C¸Ì´N¥u¬O¦r¤¸! ³Ì«á±µ{§Ç¶K¨ìÀx¦s®æ¸Ì·|Åܦ¨¶W³sµ²¤½¦¡
If C > Cx Then
'¡ôCx¦pªG¦¸¼Æ²Öp ¤j©ó Cx(³o¤£ª¾¹D¬O¤°»òªºµu¾ã¼Æ??) (Cxªºªì©lȬO 0)
Cx = C
'¡ôCx¬On¸Ë¤J C¦¸¼Æ²Öp¥[ 1ªº¼Æ¦r!
'¦h³oÓ CxÅܼƥt¤@ӥتº¬O¬°¤Fnªº¦b«á±µ{§Ç¤¤ºë½TªºÀx¦s®æ¦ì¸m¶K¤JÈ
Arr(1, C + 2) = "ÃD¸¹-" & Cx
'¡ô¼ÐÃD¦C¥[§Ç¸¹
End If
b01: Next
i01: Next i
Arr(1, 2) = "¦¸¼Æ"
If Cx = 0 Then Exit Sub
'¡ô¦pªG¨S¦³¸ê®Æ!´Nµ²§ô°õ¦æ
With [h1].Resize(UBound(Arr), Cx + 2)
'¡ô±µ¤U¨Ó¬OÃö©ó[H1]Àx¦s®æ¦V¤UÂX®iArr°}¦CÁa¦V³Ì¤j¦C¸¹,¦V¥kÂX®i ¼ÐÃD¦C_ÃD¸¹§Ç¸¹¦A¥[ 2 Äæ
.Value = Arr
'¡ô±NArr°}¦Cȱq [h1]¶}©l±a¤J
.EntireColumn.AutoFit
'¡ô³o¨ÇÄæ¦ì¦Û°Ê½Õ¾ãÄæ¼e
End With
End Sub |
|