Skip to content

Instantly share code, notes, and snippets.

Last active Jun 6, 2019
What would you like to do?
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
'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
End With
End If
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment