| ©«¤l1018 ¥DÃD15 ºëµØ0 ¿n¤À1058 ÂI¦W0  §@·~¨t²Îwin7 32bit ³nÅ骩¥»Office 2016 64-bit ¾\ŪÅv50 ©Ê§O¨k ¨Ó¦Û®ç¶é µù¥U®É¶¡2012-5-9 ³Ì«áµn¿ý2022-9-28 
 | 
                
| ¦^´_ 1# softsadwind ½Æ»s¥N½XPrivate Sub CommandButton1_Click()
    Application.ScreenUpdating = False
    
    'clear
    Range("G4").Resize(UsedRange.Rows.Count - 3, 4).Clear
    Sheets("¿z¿ï").Range("G:J").Clear
    
    'filter copy
    Range("A:D").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("G1:I2"), CopyToRange:=Sheets("¿z¿ï").Range("G:J"), Unique:=False
    
    'sort, copy back
    Dim R2 As Long
    With Sheets("¿z¿ï")
        R2 = .Range("G65536").End(xlUp).Row
        .Range("G1:J" & R2).Sort Key1:=.Range("I2:I" & R2), Key2:=.Range("G2:G" & R2), Key3:=.Range("H2:H" & R2), Header:=xlYes
        .Range("I1:I" & R2).Copy [G4]
        .Range("G1:H" & R2).Copy [H4]
        .Range("J1:J" & R2).Copy [J4]
    End With
    
    '®æ¦¡®Ø½u
    Dim i, j
    With Range(Range("G4"), Range("G4").End(xlDown))
        For i = .Columns(1).Rows.Count To 2 Step -1
            'product
            If .Cells(i, 1).Value <> .Cells(i - 1, 1) Then
                .Cells(i, 1).Resize(, 4).Borders(xlEdgeTop).LineStyle = xlContinuous
            Else
                .Cells(i, 1).Value = ""
                .Cells(i, 1).Borders(xlEdgeTop).LineStyle = xlNone
                
                'customer
                If .Cells(i, 2).Value <> .Cells(i - 1, 2) Then
                    .Cells(i, 2).Resize(, 3).Borders(xlEdgeTop).LineStyle = xlContinuous
                Else
                    .Cells(i, 2).Value = ""
                    .Cells(i, 2).Resize(, 3).Borders(xlEdgeTop).LineStyle = xlNone
                End If
            End If
            
        Next i
    End With
    
    Application.ScreenUpdating = True
End Sub
 | 
 |