Guest User

Untitled

a guest
Apr 12th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. Function myTime(myRng As Range) As String
  2. Dim Addr As String, sTime As String, eTime As String
  3. Dim first As Long, last As Long, i As Long
  4.  
  5. Addr = myRng.Address
  6. first = Range(Split(Addr, ":")(0)).Column
  7. last = Range(Split(Addr, ":")(1)).Column
  8.  
  9. If Application.CountA(myRng) = 0 Then
  10. myTime = ""
  11. Exit Function
  12. End If
  13.  
  14. For i = first To last
  15. Select Case UCase(Cells(myRng.Row, i))
  16. Case "X", "S", "R", "G", "C", "A", "M", "T", "B", "x", "s", "r", "g", "c", "a", "m", "t", "b"
  17. sTime = Format((i - 3) / 48, "hh:mm")
  18. Exit For
  19. End Select
  20. Next
  21. For i = last To first Step -1
  22. Select Case UCase(Cells(myRng.Row, i))
  23. Case "X", "S", "R", "G", "C", "A", "M", "T", "B", "x", "s", "r", "g", "c", "a", "m", "t", "b"
  24. eTime = Format((i - 2) / 48, "hh:mm")
  25. Exit For
  26. End Select
  27. Next
  28. myTime = sTime & " - " & eTime
  29. End Function
Add Comment
Please, Sign In to add comment