excel - A cell has 3 inserted lines of data. How to split it into rows for each line of data -
2 lines of dates (it anything) in cell. need detect entries in cell separated \n (new line?), , have function split cell each line entry.
so imagine somewhere detect character new line (\n or else) , there start create new cells grabbing data detected before \n
assuming data in column a , want output splitting data in column c, following might helpful:
option explicit sub splitcell() dim lastrow long, rowind long, long dim temparr variant dim ws worksheet set ws = thisworkbook.sheets("sheet1") 'change sheet1 worksheet ws rowind = 1 lastrow = .cells(.rows.count, "a").end(xlup).row 'get last row data in column = 1 lastrow 'looping tgrough cells in column temparr = split(.range("a" & i), chr(10)) 'chr(10) line break code .range("c" & rowind).resize(ubound(temparr) + 1, 1) = application.transpose(temparr) rowind = rowind + ubound(temparr) + 1 next end end sub see image reference.


Comments
Post a Comment