分享一段统计工作时间的VB代码,该怎么处理

分享一段统计工作时间的VB代码
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

  Cells(3, "V") = "工作时长"
  Cells(3, "X") = "姓名"
  Cells(3, "Y") = "月度总工时"
  Cells(3, "Z") = "标准工时"
  Cells(3, "AA") = "日平均工时"
  Range("V3").HorizontalAlignment = Excel.xlCenter
  Range("V:V").ColumnWidth = 12
  Range("Y:Y").ColumnWidth = 15
  Range("Z:Z").ColumnWidth = 10
  Range("AA:AA").ColumnWidth = 15
  Range("Y3").HorizontalAlignment = Excel.xlCenter
   
  namerow = 4
  nametext = ""
  Dim minutes
  Dim summinutes
  summinutes = 0
   
  Dim days
  days = 15

  Dim begintime
  Dim endtime
  For m = 4 To 200
  endtime = Cells(m, "F")
  If endtime = "" Then '行末尾
  '最后一个人统计
  If m > 4 Then
  'If summinutes >= 40 * 60 Then
  Cells(namerow - 1, "Y") = (summinutes) \ 60 & "小时" & (summinutes) Mod 60 & "分钟"
  Cells(namerow - 1, "Y").Interior.ColorIndex = 0
  Cells(namerow - 1, "Z") = (8 * 60 * days) \ 60 & "小时" ' & (8 * 60 * days) Mod 60 & "分钟"
  Cells(namerow - 1, "AA") = (summinutes \ days) \ 60 & "小时" & (summinutes \ days) Mod 60 & "分钟"
  ' Else
  'Cells(namerow - 1, "Y") = (40 * 60 - summinutes) \ 60 & "小时" & (40 * 60 - summinutes) Mod 60 & "分钟"
  If (summinutes - days * 8 * 60) < 0 Then
  Cells(namerow - 1, "Y").Interior.ColorIndex = 3
  End If
  End If
  '边框
  'Range("X3","Y" & namerow)
  Exit For
  End If

  If nametext <> Cells(m, "D") Then
  nametext = Cells(m, "D")
  Cells(namerow, "X") = nametext
   
  '计算总计
  If m > 4 Then
  'If summinutes >= 40 * 60 Then
  Cells(namerow - 1, "Y") = (summinutes) \ 60 & "小时" & (summinutes) Mod 60 & "分钟"
  Cells(namerow - 1, "Y").Interior.ColorIndex = 0
  Cells(namerow - 1, "Z") = (8 * 60 * days) \ 60 & "小时" ' & (8 * 60 * days) Mod 60 & "分钟"
  Cells(namerow - 1, "AA") = (summinutes \ days) \ 60 & "小时" & (summinutes \ days) Mod 60 & "分钟"
  'Else
  ' Cells(namerow - 1, "Y") = "缺" & (40 * 60 - summinutes) \ 60 & "小时" & (40 * 60 - summinutes) Mod 60 & "分钟"
  If (summinutes - days * 8 * 60) < 0 Then
  Cells(namerow - 1, "Y").Interior.ColorIndex = 3
  End If
  End If
  summinutes = 0
  namerow = namerow + 1
  End If
   
  begintime = endtime
  For n = 7 To 21
  If Cells(m, n) > endtime Then