Option Explicit
Sub XepThuHang()
Dim lRow As Long, iJ As Long
' Dim dDiem As Double: Dim bHang As Byte'
lRow = Sheet3.Range("B1").CurrentRegion.Rows.Count
' lRow = Sheet3.UsedRange.Rows.Count
' lRow = Sheet3.Range("B65432").End(xlUp).Row
Chep
Columns("A:C").Select
Selection.Sort Key1:=Range("C2"), Order1:=xlDescending, Key2:=Range("A2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
Application.ScreenUpdating = False
Range("D2") = 1
For iJ = 3 To lRow
With Cells(iJ, 3)
If .Value = .Offset(-1) Then
.Offset(, 1) = .Offset(-1, 1)
Else
.Offset(, 1) = 1 + .Offset(-1, 1)
End If
End With
Next iJ
Columns("A:D").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Cells(2, 2).Select
End Sub