Thread: Text to Numbers
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
clk clk is offline
external usenet poster
 
Posts: 17
Default Text to Numbers

On Nov 5, 1:39*pm, Gary''s Student
wrote:
Try this small UDF:

Function seconds(r As Range) As Long
labell = Array("second", "minute", "hour", "day")
faktor = Array(1, 60, 3600, 86400)
seconds = 0
v = r.Value
ary = Split(v, ", ")
For i = LBound(ary) To UBound(ary)
* * parts = Split(ary(i), " ")
* * For j = 0 To 3
* * * * If InStr(parts(1), labell(j)) 0 Then
* * * * * * seconds = seconds + parts(0) * faktor(j)
* * * * End If
* * Next
Next
End Function

So if A1 contains:

3 hours, 57 minutes, 43 seconds

the formula:
=seconds(A1) will display 14263

--
Gary''s Student - gsnu200812



"clk" wrote:
Hi everyone. *I have a column of data imported into excel that has
text and numbers. *Such as 3 hours, 57 minutes, 43 seconds. *It might
also just have 39 seconds or 1 day, 4 hours, 45 minutes. *It would
look like this:


A1
3 hours, 57 minutes, 43 seconds
39 seconds
1 day, 4 hours, 45 minutes


I need to take this column and convert each entry to seconds. *f
anyone can think of a way to do this it would be greatly appreciated.- Hide quoted text -


- Show quoted text -


Thank you so much for the ideas. I used the option of splitting the
columns up and using the formula. Worked great! Thanks again.