parsing - VBA parse string Place values to new columns -
i have sheets rows of data like.
nom(lsl,usl)=207.3980(206.1990,208.5970) nom(lsl,usl)=207.3980(206.1990,208.5970) nom(lsl,usl)=18.8200(18.4400,19.2100)
i grab values , place them in own cells like
207.3980 207.3980 18.8200 206.1990 206.1990 18.4400 208.5970 208.5970 19.2100
i continue recieve "byref argument mismatch" errors. believe relating how defining reference cell.
sub parse_replace() dim double dim ws worksheet set ws = thisworkbook.activesheet dim col range dim rlastcell range set rlastcell = ws.cells.find(what:="*", after:=ws.cells(1, 1), lookin:=xlformulas, lookat:= _ xlpart, searchorder:=xlbycolumns, searchdirection:=xlprevious, matchcase:=false) = rlastcell.column 1 step -1 col = collett(rlastcell.column) columns(i).cells(4) = splitstring(col3, ",", 4) columns(i).cells(5) = splitstring(col3, ",", 5) columns(i).cells(6) = splitstring(col3, ",", 6) next end sub function collett(col integer) string if col > 26 collett = collett((col - (col mod 26)) / 26) + chr(col mod 26 + 64) else collett = chr(col + 64) end if end function function splitstring(pvalue string, pchar string, pindex integer) variant dim ystring variant ystring = replace(replace(replace(replace(pvalue, " ", ""), "=", ""), "(", ","), ")", ",") splitstring = split(ystring, pchar)(pindex - 1) end function
process
- establish number of columns data
loop through each column
convert column index column
collett
set cell value
splitstring
loop
thank you
edit : replaced splitstring
value inteded.
you declare col
range here:
dim col range
you try set col
string here:
col = collett(rlastcell.column)
when set range have set range. furthermore, have use set
keyword so:
set col = <a range>
when set col
set rlastcell.column
repeatedly in each loop of for
. if need column letter last column, before entering loop.
all of pointless anyway. @ no point use column letter went through trouble retrieving in function. , really, doing don't need column letter. column letters humans; column number important in vba how.
Comments
Post a Comment