vba - Excel - split and transpose with inserted rows -
vba - Excel - split and transpose with inserted rows -
what code using accomplish in vba, i've been trying adapt other codes have seen online needs it's not working out. i'll appreciate help.
i info in format:
col col b col c col d qbc t 90125 lak-912,323.yvs-pk,us. qol t 53241 lwa-324. qef f 31236 pks-634,432,243.
and info extracted as:
col col b col c col d qbc t 90125 lak-912 qbc t 90125 lak-323 qbc t 90125 yvs-pk qbc t 90125 yvs-us qol t 53241 lwa-324 qef f 31236 pks-634 qef f 31236 pks-432 qef f 31236 pks-243
hope clear!
this sub create list cell f2:
dim lastrow long dim rowsoffset, colsoffset, e, k long dim str string dim strb, strn string dim start long range("a1").activate lastrow = range(activecell.specialcells(xllastcell).address).row rowsoffset = 0 colsoffset = 5 e = 1 lastrow str = activecell.offset(e, 3).value strb = "" strn = "" start = 1 k = 1 len(str) if mid(str, k, 1) = "," strn = mid(str, start, k - start) start = k + 1 rowsoffset = rowsoffset + 1 activecell.offset(rowsoffset, colsoffset).value = activecell.offset(e, 0).value activecell.offset(rowsoffset, colsoffset + 1).value = activecell.offset(e, 1).value activecell.offset(rowsoffset, colsoffset + 2).value = activecell.offset(e, 2).value activecell.offset(rowsoffset, colsoffset + 3).value = strb & strn end if if mid(str, k, 1) = "." strn = mid(str, start, k - start) start = k + 1 rowsoffset = rowsoffset + 1 activecell.offset(rowsoffset, colsoffset).value = activecell.offset(e, 0).value activecell.offset(rowsoffset, colsoffset + 1).value = activecell.offset(e, 1).value activecell.offset(rowsoffset, colsoffset + 2).value = activecell.offset(e, 2).value activecell.offset(rowsoffset, colsoffset + 3).value = strb & strn end if if mid(str, k, 1) = "-" strb = mid(str, start, k - start + 1) start = k + 1 end if next
if want position, change:
rowsoffset = 0 ' rows offset colsoffset = 5 ' column offset
if want sheet, code it's little different. need alter 8 line activecell with:
sheets("sheet2").range("a1").offset(rowsoffset, colsoffset).value = activecell.offset(e, 0).value
excel vba split transpose
Comments
Post a Comment