- ©«¤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-25 10:36 ½s¿è
¦^´_ 6# cypd
ÁÂÁ«e½ú¦^´_
½Ð¨Ï¥Î ã´£³¡ªL«e½úªº¤è®×!«á¾Çªº½m²ß·í°Ñ¦Ò´N¦n
¦]¬°VBA»P¤½¦¡²V¥Î»Ýn½ÆÂøÂIªº·Qªk¤~¤ñ¸û¦w¥þ!
¤£µM·|¦³¥Î¿ù³øªíªºÅU¼{
½Ð«e½úÌ«ü¥¿¨Ã«ü¾É!ÁÂÁÂ
¥H¤U¬O«á¾Çªº¾Ç²ß¤ß±oµù¸Ñ:
Option Explicit
Dim WNa
'¡ô«Å§i¼Ò²ÕÅܼÆ
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'¡ôÂùÀ»Ä²µo
With Target
'¡ô¥H¤UÃö©óIJµo
If .Address = "$A$2" Then
'¡ô¦pªGIJµoªºÀx¦s®æ¦ì§}¬O [A2]
ActiveSheet.Copy
'¡ô¾ãÓ²{¥Î¤u§@ªí½Æ»s¨ì·sªº¬¡¶Ã¯
Set WNa = ActiveWorkbook.ActiveSheet
'¡ô¥OWNa ¬O³o·s¬¡¶Ã¯ªº²{¥Î¤u§@ªí(¥H¤UºÙ:·sªí)
MsgBox "µ²ªG©ñ¦b·s¼W¬¡¶Ã¯: " & ActiveWorkbook.Name
'¡ô¸õ¥X´£¥Üµ¡: µ²ªG©ñ¦b·s¼W¬¡¶Ã¯: ¬¡¶Ã¯¦WºÙ
Call test
'¡ô°õ¦æ°Æµ{¦¡ test()
Cancel = True
'¡ô¨ú®ø 쥻ÂùÀ»Àx¦s®æ¥i¦bÀx¦s®æ¤º½s¿è¤å¦r ªº¥\¯à°õ¦æ
End If
End With
End Sub
Private Sub test()
Dim Brr, Crr, i&, x, Y, K&
Dim ³¡ªù$, ì»ù&, ¥»¦~&, ²Öp&, ª÷ÃB&, ¼W´î$
'¡ô«Å§iÅܼÆ
Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OY ¬O¦r¨å
Brr = WNa.Range(WNa.[P1], WNa.[A65536].End(3))
'¡ô¥OBrr¬O°}¦C! ˤJ·sªíªº[P1]¨ì ·sªíAÄæ³Ì«á¤@Ó¦³¤º®eªºÀx¦s®æ ¤§¶¡¤è¥¿°Ï°ìÀx¦s®æªºÈ
For i = 5 To UBound(Brr)
'¡ô³]¶¶°j°é! ±q5 ¨ìBrr°}¦CÁa¦V³Ì«á¦C¸¹
³¡ªù = Brr(i, 1)
'¡ô¥O³¡ªù$ ³oÅÜ¼Æ ¬OBrr°}¦Cªº²Ä¤@Äæ°j°é¦C¦ì¸m¦r¦ê
ì»ù = Brr(i, 8)
'¡ô¥Oì»ù& ³oÅÜ¼Æ ¬OBrr°}¦Cªº²Ä¤KÄæ°j°é¦C¦ì¸m¼Æ¦r
¥»¦~ = Brr(i, 9)
'¡ô¥O¥»¦~& ³oÅÜ¼Æ ¬OBrr°}¦Cªº²Ä¤EÄæ°j°é¦C¦ì¸m¼Æ¦r
²Öp = Brr(i, 10)
'¡ô¥O²Öp& ³oÅÜ¼Æ ¬OBrr°}¦Cªº²Ä¤QÄæ°j°é¦C¦ì¸m¼Æ¦r
ª÷ÃB = Brr(i, 11)
'¡ô¥Oª÷ÃB& ³oÅÜ¼Æ ¬OBrr°}¦Cªº²Ä¤Q¤@Äæ°j°é¦C¦ì¸m¼Æ¦r
¼W´î = Brr(i, 16)
'¡ô¥O¼W´î$ ³oÅÜ¼Æ ¬OBrr°}¦Cªº²Ä¤Q¤»Äæ°j°é¦C¦ì¸m¦r¦ê
If Y.Exists(³¡ªù) = False Then
'¡ô¦pªGY¦r¨å¸Ì¨S¦³ °j°éÅܼƳ¡ªùªºkey(Áä) ??
Set Y(³¡ªù) = CreateObject("Scripting.Dictionary")
'¡ô¥O °j°éÅܼƳ¡ªùªºkey ¬O¦r¨å!
'¥Hi¬O5¬°¨Ò:³¡ªù¬OÀç·~³¡,"Àç·~³¡"¥O¥L¥Í¦¨¤@Óª«¥ó¦r¨å:
'¤]´N¬OY¦r¨å¤¤¦³¤@Ó "Àç·~³¡"ªº key,
'¦P®É¤S¦s¦bµÛ¤@³¡¦r¨å¦W¥s "Àç·~³¡"
'©Ò¥H³o¦æµ{¦¡½X¦@°µ¤F¨â¥ó¨Æ
End If
If ¼W´î = "" Or ¼W´î = "¼W¥[" Then
'¡ô¦pªG¼W´î$ ³o¦r¦êÅÜ¼Æ ¬OªÅ¥Õ ©Î ³o¦r¦êÅÜ¼Æ ¬O"¼W¥["¦r¦ê??
Y(³¡ªù)(1) = Y(³¡ªù)(1) + ì»ù
'¡ô·íi=5
'¥OY¦r¨å¤¤key¬O Àç·~³¡ªº¦r¨å¸Ìªºkey¬O1ªºitem,²Ö¥[ ì»ù& ³oÅܼƪº¼Æ¦r
'©Ò¥H³o¦æµ{¦¡½X¤]°µ¤F¨â¥ó¨Æ:
'1.¦]¬°Y¦r¨å¤¤Àç·~³¡ªº¦r¨å¸Ì쥻¨S¦³ 1ªºkey,
'·í§ÚÌ¥O Y(³¡ªù)(1) = ³o°Ê§@´N¤w¸g¦Û°Ê¥Í¦¨ Y¦r¨å¤¤Àç·~³¡ªº¦r¨å¸Ì 1ªºkey
'2.¦Ó = Y(³¡ªù)(1) + ì»ù& ´N¬O Y¦r¨å¤¤Àç·~³¡ªº¦r¨å¸Ì key¬O1 ªºitem
'¬°¤°»òn ¦bY¦r¨å¤¤Àç·~³¡ªº¦r¨å¸Ì³]¤@Ókey¬O1,Item¬Oì»ù&²Ö¥[È??
'¦]¬°key 1¬On«ü©w«á±µ{§Çn©ñ¦bCrr°}¦Cªº¦ì¸m ¦pµù¸Ñ¼Ð°O @1
Y(³¡ªù)(2) = Y(³¡ªù)(2) + ¥»¦~
'¡ô³o¦æµ{¦¡½XÃþ±À
Y(³¡ªù)(3) = Y(³¡ªù)(3) + ²Öp
'¡ô³o¦æµ{¦¡½XÃþ±À
Y(³¡ªù)(4) = Y(³¡ªù)(4) + ª÷ÃB
'¡ô³o¦æµ{¦¡½XÃþ±À
If ¼W´î = "¼W¥[" Then
Y(³¡ªù)(5) = Y(³¡ªù)(5) + ì»ù
'¡ô³o¦æµ{¦¡½XÃþ±À!¥u¬O¦h¥[¤F¤@Ó§PÂ_:¦pªG ¼W´î$³o¦r¦êÅܼƬO "¼W¥["
End If
ElseIf ¼W´î = "´î¤Ö" Then
Y(³¡ªù)(6) = Y(³¡ªù)(6) + ì»ù
Y(³¡ªù)(7) = Y(³¡ªù)(7) + ²Öp
Y(³¡ªù)(9) = Y(³¡ªù)(7)
Y(³¡ªù)(10) = Y(³¡ªù)(10) + ª÷ÃB
'¡ô³o¦æµ{¦¡½XÃþ±À!¥u¬O¦h¥[¤F¤@Ó§PÂ_:§_«h¦pªG ¼W´î$³o¦r¦êÅܼƬO "´î¤Ö"
End If
Next
ReDim Crr(1 To Y.Count + 1, 1 To 11)
'¡ô«Å§iCrr°}¦Cªº½d³ò:Áa¦V¬O±q1¨ìY¦r¨å¸Ì¦@¦³´XÓ³¡ªùªºkeyªº¼Æ¶q¦C¦A¥[1,
'¦A¥[1 ¬O¬°¤Fn©ñÁ`¦Xp
'¾î¦V¬O±q1 ¨ì11 ,¦]¬°µ²ªG¦ì¸m¦³11Äæ T:AD
For Each x In Y.KEYS
'¡ô³]¥~¶¶°j°é!¥Ox ¬OY¦r¨å·í¤¤ªº¤@Ókey!±q Àç·~³¡ ¨ì ¬ãµo³¡
K = K + 1
'¡ô¥OK ²Ö¥[1,«e±¬O«Å§iK ¬Oªø¾ã¼Æ,©Ò¥H±q0¶}©l²Ö¥[1
Crr(K, 1) = x
'¡ô°j°é¤@¶}©l¥OCrr°}¦C²Ä¤@¦C²Ä¤@Äæ¦ì¸m¬O "Àç·~³¡" ¦r¦ê
'«áÄò°j°é....
For i = 2 To 11
'¡ô³]¤º¶¶°j°é±q2 ¨ì11
Crr(K, i) = Y(x)(i - 1) '@1
'¡ô¥OCrr°}¦C¬Û¹ïªº¦ì¸m¸Ë¤J ¬dY¦r¨å¤¤ªº¦r¨åªºitem
Crr(UBound(Crr), i) = Crr(UBound(Crr), i) + Y(x)(i - 1)
'¡ô¥OCrr°}¦Cªº³Ì«á¦C²Ö¥[¨C¤@¶µ ¬dY¦r¨å¤¤ªº¦r¨åªºitem
Next
Next
Crr(UBound(Crr), 1) = "¦Xp"
'¡ô¥OCrr°}¦Cªº³Ì¥ª¤U¨¤¨º¦ì¸m¬O "¦Xp" ¦r¦ê
WNa.[T5].Resize(UBound(Crr), 11) = Crr
'¡ô±NCrr°}¦CÈˤJ·sªí,±q·sªí[T5]¦V¤UÂX®i Crr°}¦CÁa¦V¦C¸¹¼Æ,¦V¥kÂX®i11Äæ,
'ˤJ³o½d³ò¸Ì
WNa.[H2] = Crr(UBound(Crr), 2)
'¡ô¥O·sªí[H2]ȬO Crr°}¦C³Ì¤U±¦C¦ì,¥k²Ä¤GӼƦr
WNa.[I2] = Crr(UBound(Crr), 3)
'¡ô¥O·sªí[I2]ȬO Crr°}¦C³Ì¤U±¦C¦ì,¥k²Ä¤TӼƦr
WNa.[J2] = Crr(UBound(Crr), 4)
'¡ô¥O·sªí[I2]ȬO Crr°}¦C³Ì¤U±¦C¦ì,¥k²Ä¥|ӼƦr
WNa.[K2] = Crr(UBound(Crr), 5)
'¡ô¥O·sªí[K2]ȬO Crr°}¦C³Ì¤U±¦C¦ì,¥k²Ä¤Ó¼Æ¦r
Set Y = Nothing
Set Brr = Nothing
Set Crr = Nothing
End Sub
³o¨Çµ{¦¡½Xn©ñ¦b¤u§@ªí¼Ò²Õ¸Ì¤~¯à¥Î |
|