Sub DanhSoThuTuTheoNgay()
Dim fDat As Date, lDat As Date, SoNgay As Integer, Rws As Long, Dm As Integer, J As Long
Dim WF As Object, Rng As Range, sRng As Range
Dim MyAdd As String, MyFormat As String
Set WF = Application.WorksheetFunction
With Sheet1.[E1]
Rws = .CurrentRegion.Rows.Count: Set Rng = .Resize(Rws)
fDat = .Offset(1).Value: lDat = .Offset(Rws - 2).Value
SoNgay = lDat - fDat
Rng.Offset(1).NumberFormat = "mm/dd/yyyy"
End With
For J = 0 To SoNgay
Set sRng = Rng.Find(Format(J + fDat, "MM/DD/yyyy"), , xlFormulas, xlWhole)
If Not sRng Is Nothing Then
MyAdd = sRng.Address
Do
Dm = Dm + 1: Cells(sRng.Row, "A").Value = Dm
Set sRng = Rng.FindNext(sRng)
Loop While Not sRng Is Nothing And sRng.Address <> MyAdd
Dm = 0
End If
Next J
End Sub