Private Sub Worksheet_Change(ByVal Target As Range)
  Dim aTime()
  Application.EnableEvents = False
  Application.ScreenUpdating = False
  If Target.Address(0, 0) = "B5" Then
    Range("A8:B23").ClearContents
    If Len(Target.Value) > 0 Then Call ThoiGian(aTime, Target.Value)
  ElseIf Target.Address(0, 0) = "E5" Then
    Range("B8:B23").ClearContents
    aTime = Range("A8:A23").Value
    If Len(Target.Value) > 0 Then Call MucTieu(aTime, Target.Value)
  End If
  Application.ScreenUpdating = True
  Application.EnableEvents = tue
End Sub
Private Sub MucTieu(aTime, ByVal tmp As String)
  Dim Res()
  Dim eRow&, eCol&, sRow&, i&, NL, d, t
  With Sheets("NLSX")
    eRow = .Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To eRow
      If .Cells(i, 1).Value = tmp Then
        NL = .Cells(i, 2).Value
        Exit For
      End If
    Next i
  End With
  If Len(NL) = 0 Then Exit Sub
  sRow = UBound(aTime)
  ReDim Res(1 To sRow, 1 To 1)
  For i = 1 To sRow
    If InStr(1, aTime(i, 1), "~") > 0 Then
      s = Split(aTime(i, 1), "~")
      d = NL * (CDate(s(1)) - CDate(s(0))) * 24
      t = t + d
      Res(i, 1) = d & Chr(10) & "  " & t
    End If
  Next i
  Range("B8").Resize(sRow) = Res
End Sub
Private Sub ThoiGian(aTime, ByVal tmp As String)
  Dim eRow&, eCol&, j&
  With Sheets("Time")
    eCol = .Cells(3, 1000).End(xlToLeft).Column
    For j = 2 To eCol
      If .Cells(3, j).Value = tmp Then
        eRow = .Cells(Rows.Count, j).End(xlUp).Row
        If eRow > 3 Then
          aTime = .Range(.Cells(4, j), .Cells(eRow, j)).Value
          Range("A8").Resize(eRow - 3).Value = aTime
          Exit For
        End If
      End If
    Next j
  End With
  If Len(Range("E5").Value) > 0 Then
    Call MucTieu(aTime, Range("E5").Value)
  End If
End Sub