Last active
June 6, 2019 08:37
-
-
Save DuongAQ/1e9284ea1fa5d0acdec737421e7582b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub SapXep() | |
'Bien dong cuoi | |
Dim lr As Long | |
lr = Worksheets("Data").Cells(Rows.Count, 1).End(xlUp).Row | |
'Dieu kien chi sap xep khi bang tinh co du lieu | |
If lr > 1 Then 'Dong tieu de la dong 1 | |
'Xoa cac noi dung sap xep truoc do | |
ActiveWorkbook.Worksheets("Data").Sort.SortFields.Clear | |
'Sap xep | |
ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add2 Key:=Range("A2:A" & lr), _ | |
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal | |
With ActiveWorkbook.Worksheets("Data").Sort | |
.SetRange Range("A1:E" & lr) | |
.Header = xlYes | |
.MatchCase = False | |
.Orientation = xlTopToBottom | |
.SortMethod = xlPinYin | |
.Apply | |
End With | |
End If | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment