One cell calculation Excel - Time Interval
Solved/Closed
Related:
- One cell calculation Excel - Time Interval
- Vat calculation excel - Guide
- Calculation is incomplete excel - Guide
- Popcorn time apk - Download - Movies, series and TV
- Excel mod apk for pc - Download - Spreadsheets
- Excel multiple lines in one cell - Guide
3 responses
rizvisa1
Posts
4478
Registration date
Thursday 28 January 2010
Status
Contributor
Last seen
5 May 2022
766
7 Jul 2010 à 11:26
7 Jul 2010 à 11:26
So would your data always look like
<date 1><space><time 1><space><date2><space><time 2>
or could you have other combinations too ?
<date 1><space><time 1><space><date2><space><time 2>
or could you have other combinations too ?
rizvisa1
Posts
4478
Registration date
Thursday 28 January 2010
Status
Contributor
Last seen
5 May 2022
766
7 Jul 2010 à 19:36
7 Jul 2010 à 19:36
Try this. You need to format the cell as number to decimal position as you desire. or you can send the formatted value from here like DateDiff = Format((CDate(sDt2) - CDate(sDt1)) * 24, "0")
Public Function DateDiff(ByVal sDateString As Range) As Variant
Dim vPos As String
Dim sDt1 As String
Dim sDt2 As String
If Trim(sDateString) = vbNullString Then
DateDiff = vbNullString
Else
vPos = InStr(1, sDateString, " ") ' marks end of date part 1
vPos = InStr(vPos + 1, sDateString, " ") ' marks end of time part 1
sDt1 = Left(sDateString, vPos - 1) ' date and time part 1
sDt2 = Mid(sDateString, vPos + 1) ' date and time part 2
DateDiff = (CDate(sDt2) - CDate(sDt1)) * 24
End If
End Function
7 Jul 2010 à 12:53