Option Explicit
Public Sub Tang_Top5()
On Error Resume Next
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Sheets("Thong ke GD").Select
Range("A8:V8").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="5", Operator:=xlBottom10Items
Dim endRow As Long
endRow = Range("B65536").End(xlUp).Row
If endRow >= 9 Then
Range("B9:B" & endRow & ",E9:E" & endRow & ",T9:T" & endRow & ",V9:V" & endRow).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("Tam").Select
Range("A1").Select
ActiveSheet.Paste
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Sheets("Thong ke").Select
Sheets("Thong ke").Range("B4:E8").Value = Sheets("Tam").Range("A1:D5").Value
Sheets("Tam").Range("A1:D5").Clear
End If
Sheets("Thong ke GD").Select
Selection.AutoFilter
Sheets("Thong ke").Select
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub