Этот мой предыдущий ответ поможет вам в этом.
Небольшая корректировка:
=VALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B5,"d"," "),"h",":"),
"min",":"),"s",""))
А затем отформатируйте ячейку как [h]:mm:ss
, где [h]
означает, что число часов может быть больше 24 (вместо перехода к нулю),
Я не утверждаю, что эта формула будет работать во всех ваших случаях.На самом деле, он терпит неудачу, когда у вас есть только минуты, секунды, дни и минуты, но нет часов и т. Д. Но вы просите «помощи или подсказок», и это действительно должно дать вам отправную точку для разработки формулы, которая подходитдля ваших обстоятельств.
РЕДАКТИРОВАТЬ Я не мог устоять.Я сделал пользовательскую функцию VBA, которая анализирует ваши строки дат.Он достаточно надежен и работает для всех ваших примеров и даже больше, даже для строки со случайными символами, например, 6d 243min + 7s
.Обратите внимание, что вы все равно должны отформатировать ячейки как [h]:mm:ss
.
Function ParseDateTime(sTime As String) As Date
Dim i As Long
Dim identifierPos As Long
Dim iTimeUnit As Long
Dim nTimeUnit As Long
Dim timeUnitCount As Long
Dim timeUnitIdentifier() As String
Dim timeUnitDateValue() As Date
Dim thisDate As Date
' What are we looking for in the string?
ReDim timeUnitIdentifier(1 To 4)
timeUnitIdentifier(1) = "d"
timeUnitIdentifier(2) = "h"
timeUnitIdentifier(3) = "min"
timeUnitIdentifier(4) = "s"
' What does each of these identifiers mean?
ReDim timeUnitDateValue(1 To 4)
timeUnitDateValue(1) = 1 ' value of 1 means 1 day in Date type.
timeUnitDateValue(2) = TimeSerial(1, 0, 0)
timeUnitDateValue(3) = TimeSerial(0, 1, 0)
timeUnitDateValue(4) = TimeSerial(0, 0, 1)
nTimeUnit = UBound(timeUnitIdentifier)
' Treat each time unit separately
For iTimeUnit = 1 To nTimeUnit
' Try to locate this time unit's identifier
identifierPos = InStr(sTime, timeUnitIdentifier(iTimeUnit))
If identifierPos > 0 Then
' Found it. Extract the digits that precede the identifier.
For i = identifierPos - 1 To 1 Step -1
If Not (Mid(sTime, i, 1) Like "[0-9]") Then
Exit For
End If
Next i
timeUnitCount _
= CLng(Mid(sTime, i + 1, identifierPos - i - 1))
thisDate = thisDate _
+ timeUnitCount * timeUnitDateValue(iTimeUnit)
Else
' Identifier not found. Do nothing.
End If
Next iTimeUnit
ParseDateTime = thisDate
End Function