Heads-up… If any of the answers worked or pointed you in the right direction, please respond to the answer(s) saying "Solution Verified" to award a ClippyPoint (doing that also marks your post as solved). You can't do the SV reply on yourself. :)
in B1 =TRIM(LEFT(A1,FIND(" ",A1&" "))) will return the first bit
in C1 =IFERROR(LEFT(B1,LEN(B1)-1)*CHOOSE(MATCH(RIGHT(B1,1),{"d","h","m","s","w"}),1,TIME(1,0,0),TIME(0,1,0),TIME(0,0,1),7),0) will convert B1 to Excel serial date time
in D1 =TRIM(SUBSTITUTE(A1,B1,"",1)) returns the second bit
and in E1 =IFERROR(LEFT(D1,LEN(D1)-1)*CHOOSE(MATCH(RIGHT(D1,1),{"d","h","m","s","w"}),1,TIME(1,0,0),TIME(0,1,0),TIME(0,0,1),7),0) will turn that into an Excel serial date/time
Function TOTIME(rng As Range) As Double
'u/excelevator r/excelevator
Dim T As Double
Dim S() As String
Dim uB As Integer
Dim Wi As Integer, Di As Integer, Hi As Integer, Mi As Integer, Si As Integer
For Each cell In rng
S = Split(cell, " ")
uB = UBound(S)
For i = 0 To uB
Select Case Right(S(i), 1)
Case "w"
Wi = Replace(S(i), "w", "")
Case "d"
Di = Replace(S(i), "d", "")
Case "h"
Hi = Replace(S(i), "h", "")
Case "m"
Mi = Replace(S(i), "m", "")
Case "s"
Si = Replace(S(i), "s", "")
End Select
Next
Next
T = DateSerial(1900, 1, (Wi * 7) + Di) + TimeSerial(Hi, Mi, Si) - 1
TOTIME = T
End Function
With this layout: https://imgur.com/5PJwr6q -- where your originals are listed down the A column, and you've got headers along row 1 in columns B thru F (for W, D, H, M, S), and your RESULT of course over in G.
Put the following formula in B2 and copy across to F2 and then down as needed:
1
u/jobby679 Sep 02 '20
Solution Verified thank you so much guys!
1
u/fuzzy_mic 988 Sep 02 '20
Is this at most two time units, i.e might there be a string "3h 44m 18s"
Is it consistent in that there is no space between a number and its unit and that there is a single space between different time units?
I see "d" for days, are there other longer abreviations (month, year, fortnight?)
1
u/Decronym Sep 02 '20 edited Sep 03 '20
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
18 acronyms in this thread; the most compressed thread commented on today has 6 acronyms.
[Thread #232 for this sub, first seen 2nd Sep 2020, 01:01] [FAQ] [Full list] ^[Contact] [Source code]
1
u/excelevator 3071 Sep 02 '20
Great question!
=TOTIME(A2)•
u/AutoModerator Sep 01 '20
/u/jobby679 - please read this comment in its entirety.
Once your problem is solved, please reply to the answer(s) saying
Solution Verifiedto close the thread.Please ensure you have read the rules -- particularly 1 and 2 -- in order to ensure your post is not removed.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/[deleted] Sep 02 '20 edited Sep 02 '20
Here's another formula w/helper columns option:
With this layout: https://imgur.com/5PJwr6q -- where your originals are listed down the A column, and you've got headers along row 1 in columns B thru F (for W, D, H, M, S), and your RESULT of course over in G.
Put the following formula in B2 and copy across to F2 and then down as needed:
Format those cells as General (or Number).
Then in G2 copied down:
Format those cells w/custom format:
[h]:mm:ssSample of results (light gray cells for first formula, dark gray for second): https://imgur.com/HEBgh3C