본문 바로가기
VBA/엑사남_기초방

[기초방] VBA 100제 #76 [ 상위랭커 구하기 ]

by 일등미노왕국 2023. 10. 17.

더보기
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

    If Intersect([c3], Target) Is Nothing Then Exit Sub
    
    [c3].Activate
    
    [j7: j1000].Clear
    Call 기초방76
    

End Sub

Option Explicit

Sub 기초방76()

    Dim vall
    Dim rngAll As Range: Set rngAll = [g6].CurrentRegion
    Dim rngX As Range: Set rngX = [j7]
    Dim rngD As Range
    
    Application.ScreenUpdating = False
    
        Set rngAll = rngAll.Offset(1).Resize(rngAll.Rows.Count - 1, 2)
        
        rngX.Consolidate rngAll.Address(1, 1, xlR1C1), xlSum, 0, 1  '= 부분합
        
        rngX.Sort [k7], 2                       '= 정렬
        
        Set rngD = rngX.Offset([c3])
        
        Range(rngD, rngD(1, 2).End(4)).Clear    '= 초기화
        
        With [j6].CurrentRegion                 '= 서식완성
        
            .HorizontalAlignment = xlCenter
            .Borders.LineStyle = 1
        
        End With
    
    Application.ScreenUpdating = True
    

End Sub

 

 

 

댓글