Convert Milliseconds To Human Readable Time Using VBA

Public Function TimeString(ByVal milliseconds As Double) As String
 Dim minutes As Long
 Dim seconds As Long
 Dim ms As Long
 Dim sTemp As String
 Dim sJoin() As String
 Dim iCount As Integer

 minutes = (milliseconds / 1000)  60
 seconds = (milliseconds  1000) Mod 60
 ms = milliseconds Mod 1000

If minutes > 0 Then
 ReDim Preserve sJoin(iCount)
 sJoin(iCount) = minutes & " min"
 iCount = iCount + 1
 End If

 If seconds > 0 Then
 ReDim Preserve sJoin(iCount)
 sJoin(iCount) = seconds & " sec"
 iCount = iCount + 1
 End If

 If ms > 0 Then
 ReDim Preserve sJoin(iCount)
 sJoin(iCount) = ms & " ms"
 iCount = iCount + 1
 End If

 If minutes = 0 And seconds = 0 And ms = 0 Then
 TimeString = "0 ms"
 Else
 TimeString = Join(sJoin, ", ")
 End If
End Function

Usage :
TimeString(162523)

2 min, 42 sec, 523 ms