| ©«¤l5923 ¥DÃD13 ºëµØ1 ¿n¤À5986 ÂI¦W0  §@·~¨t²Îwin10 ³nÅ骩¥»Office 2010 ¾\ŪÅv150 ©Ê§O¨k ¨Ó¦Û¥xÆW°ò¶© µù¥U®É¶¡2010-5-1 ³Ì«áµn¿ý2022-1-23 
         
 | 
                
| ¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-4-10 19:06 ½s¿è 
 ¦^´_ 2# melvinhsu
 ¸Õ¸Õ¬Ý
 ½Æ»s¥N½XOption Explicit
Sub testing3()
    Dim i As Integer, D1 As Object, D2 As Object, Rng As Range
    Set D1 = CreateObject("SCRIPTING.DICTIONARY")  '¦r¨åª«¥ó
    Set D2 = CreateObject("SCRIPTING.DICTIONARY")  '¦r¨åª«¥ó
    i = 2                                          '²Ä2¦C¶}©l
    
    Do While Cells(i, "G") <> ""                   '°õ¦æ°j°é±ø¥ó GÄæ<>""
        With Cells(i, "G")                         'GÄæi¦C ªºª«¥ó
            If Not D1.Exists(.Value) Then          '¦r¨åªºkey¤£¦s¦b
                D1(.Value) = Cells(i, "J")         '®w¦s¼Æ
                D2(.Value) = 0                     '¥X³f¼ÆÁ`¼Æ
            End If
            If (D1(.Value) - D2(.Value)) >= Cells(i, "H") Then '®w¦s¼Æ-¥X³f¼ÆÁ`¼Æ>=q³æ¼Æ
                Cells(i, "I") = Cells(i, "H")           'q³æ¹ê»Ú¥X³f¼Æ
                D2(.Value) = D2(.Value) + Cells(i, "I") 'q³æ¹ê»Ú¥X³f¼Æªº¥[Á`
            ElseIf (D1(.Value) - D2(.Value)) > 0 And (D1(.Value) - D2(.Value)) < Cells(i, "H") Then
                 '®w¦s¼Æ-¥X³f¼ÆÁ`¼Æ > 0                 '®w¦s¼Æ-¥X³f¼ÆÁ`¼Æ > q³æ¼Æ
                Cells(i, "I") = D1(.Value) - D2(.Value) 'q³æ¹ê»Ú¥X³f¼Æ=®w¦s¼Æ-¥X³f¼ÆÁ`¼Æ
                D2(.Value) = D2(.Value) + Cells(i, "I") '¥X³f¼ÆÁ`¼Æ=¥X³f¼ÆÁ`¼Æ+q³æ¹ê»Ú¥X³f¼Æ
            ElseIf D1(.Value) = D2(.Value) Then         'µL³f¥i¥X:®w¦s¼Æ=¥X³f¼ÆÁ`¼Æ
                Cells(i, "I") = ""
                If Not Rng Is Nothing Then
                    Set Rng = Union(Rng, Range("F" & i & ":J" & i))
                Else
                    Set Rng = Range("F" & i & ":J" & i)
                End If
            End If
        End With
        i = i + 1
    Loop
   If Not Rng Is Nothing Then Rng.Select
End Sub
 | 
 |