- ©«¤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 ©ó 2023-4-10 16:27 ½s¿è
¦^´_ 11# bhsm
ÁÂÁ«e½ú,¥H¤U¤ß±oµù¸Ñ½Ð°Ñ¦Ò
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
'¡ô·í¨Ï¥ÎªÌ©Î¥~³¡³sµ²Åܧó¤u§@ªí¤¤ªºÀx¦s®æ®É·|µo¥Í¦¹¨Æ¥ó
With Target
'¡ô¥H¤U¬OÃö©óIJµo¨Æ¥óªºµ{§Ç
If .Address = "$E$4" Or .Address = "$F$4" Then
'¡ô¦pªGIJµoÀx¦s®æ¬O[E4] ©Î[F4]ªº¦ì§}
Dim Y, S, Brr, i%, j%, T$, N&
'¡ô«Å§iÅܼÆ:(Y,S,Brr)¬O³q¥Î«¬ÅܼÆ,(i,j)¬Oµu¾ã¼Æ,T¬O¦r¦êÅܼÆ
'N¬Oªø¾ã¼Æ
Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OY³o³q¥Î«¬ÅܼƬO ¦r¨å
Brr = [F9].Resize(6, 1)
'¡ô¥OBrr³o³q¥Î«¬ÅܼƬO ¤Gºû°}¦C,¥H[F9]¦V¤UÂX®i6®æªºÀx¦s®æȱa¤J
For i = 4 To 5
'¡ô³]¶¶°j°é!i±q4¨ì 5
For j = 4 To 6
'¡ô³]¶¶°j°é!j±q4¨ì 6
T = Cells(i, 2) & "|" & Cells(j, 3)
'¡ô¥OT³o¦r¦êÅܼƬO i°j°é¦CBÄæÀx¦s®æȳs±µ "|",
'¦A³s±µ j°j°é¦CCÄæÀx¦s®æȤ§«áªº·s¦r¦ê
S = Val(Cells(i, 2)) + Val(Cells(j, 3))
'¡ô¥OS³o³q¥Î«¬ÅܼƬO i°j°é¦CBÄæÀx¦s®æÈÂà¤Æ¬°¼Æ¦rÈ,
'¥[¤Wj°j°é¦CCÄæÀx¦s®æÈÂà¤Æ¬°¼Æ¦rȤ§«áªº·s¼ÆÈ
N = N + 1: Y(T) = S
'¡ô¥ON³oªø¾ã¼ÆÅÜ¼Æ ²Ö¥[1
'¥O¥HTÅܼƬ°key,item¬OSÅܼÆ,¯Ç¤JY¦r¨å
If T = [E4] & "|" & [F4] Then Brr(N, 1) = Y(T)
'¡ô¦pªGTÅܼÆ(¦r¦ê)¦P
'[E4]Àx¦s®æȳs±µ"|" ¦A³s±µ[F4]Àx¦s®æȲզ¨ªº·s¦r¦ê??
'´N¥ONÅܼƦC²Ä1ÄæBrr°}¦CȬO ¥HTÅܼƬdY¦r¨åªºitemÈ
Next
Next
[F9].Resize(6, 1) = Brr
'¡ô[F9]¦V¤UÂX®i6®æªºÀx¦s®æÈ¥H Brr°}¦Cȱa¤J
Set Y = Nothing: Erase Brr
'¡ôÄÀ©ñÅܼÆ
End If
End With
End Sub |
|