Parece um exagero, mas você pode usar uma função definida pelo usuário, esse é o código:
Public Function toDays(datestring As String)
Dim datearray() As String
datearray = Split(datestring, " ")
totaldays = 0
totalhours = 0
totalmin = 0
totalsecs = 0
For i = LBound(datearray) To UBound(datearray)
newdata = datearray(i)
If IsNumeric(newdata) = True Then
totaldays = totaldays + newdata
i = i + 1
Else
For j = 1 To Len(newdata)
m = Mid(newdata, j, 1)
If IsNumeric(m) = False Then
separation = j
j = Len(newdata)
End If
Next j
numvalue = Mid(newdata, 1, separation - 1)
measurevalue = LCase(Mid(newdata, separation))
Select Case measurevalue
Case Is = "hr"
totalhours = totalhours + numvalue
Case Is = "m"
totalmin = totalmin + numvalue
Case Is = "s"
totalsecs = totalsecs + numvalue
End Select
End If
Next i
finalresult = Round(totaldays + (totalhours / 24) + (totalmin / 1440) + (totalsecs / 86400))
toDays = finalresult & " days"
End Function
Abra macros com ALT + F11 clique com o botão direito em This Workbook
e insira um novo módulo. Cole o código no lado direito da tela.
Agora, se seus dados estiverem na célula A1
, então, na célula A2
, você deverá colocar =toDays(A1)
.