excel - VBA TimeValue() and Spreadsheet Formula TimeValue() -
good morning all,
i have on 20,000 time inputs in column such 6/23/2015 1:05:37.7 pm
, need transfer in time value excel can manage.
i managed find workaround:
set wrtb = worksheets("test bench data") wrtb.usedrange lastrowtb = wrtb.usedrange.rows.count lastcolumntb = wrtb.usedrange.columns.count if lastrowtb > 1 'makes sure there data on worksheet if wrtb.cells(7, lastcolumntb) <> "" 'makes sure time has not been formated dim atempstb variant, tempstb() string redim tempstb(lastrowtb - 7, 1) atempstb = wrtb.range(wrtb.cells(8, 2), wrtb.cells(lastrowtb, 2)) = 1 lastrowtb - 7 tempstb(i - 1, 0) = right(atempstb(i, 1), 13) next wrtb.range(wrtb.cells(8, lastcolumntb + 2), wrtb.cells(lastrowtb, lastcolumntb + 2)).numberformat = "[h]:mm:ss.000" wrtb.cells(8, lastcolumntb + 2).formular1c1 = "=timevalue(rc[-1])" wrtb.cells(8, lastcolumntb + 2).autofill destination:=wrtb.range(wrtb.cells(8, lastcolumntb + 2), cells(lastrowtb, lastcolumntb + 2)), type:=xlfilldefault wrtb.range(wrtb.cells(8, lastcolumntb + 1), wrtb.cells(lastrowtb, lastcolumntb + 1)) = tempstb columns(lastcolumntb + 2).copy columns(lastcolumntb + 2).pastespecial paste:=xlpastevalues columns(lastcolumntb + 1).delete wrtb.usedrange lastcolumntb = wrtb.usedrange.columns.count end if end if
basically, works, ugly workaround i'd change more "professional"
if change code to:
for = 1 lastrowtb - 7 tempstb(i - 1, 0) = timevalue(right(atempstb(i, 1), 13)) next
i type mismatch error, tried setting temporary variables make sure arrays weren't causing trouble, still doesn't work...
what missing?
with data in b1, convert usable time
sub outoftime() dim s string s = range("b1").text ary = split(s, " ") range("b1").formula = "=timevalue(""" & ary(1) & " " & ary(2) & """)" end sub
Comments
Post a Comment