Microsoft Excel VBA text split tweak -
i have excel sheet uses macro split string of text when scanned (via plug&play barcode scanner) first column right using space character delimiter. example picture of excel sheet followed excel macro.
sub textsplit(rng range) dim c range, arr each c in rng.cells if len(c.value) > 0 arr = split(c.value, " ") c.offset(0, 1).resize(1, ubound(arr) + 1).value = arr end if next c end sub
now of works perfectly, need make little tweak this. i macro skip column after first serial ("cna1234567") , leave blank. how can tweak code this?
this method little more explicit , give control want.
sub textsplit(rng range) dim c range dim r long dim arr variant each c in rng.cells if len(c.value) > 0 r = c.row arr = split(c.value, " ") sheet1 .cells(r, 2).value = arr(0) '.cells(r, 3).value = <--- skipped .cells(r, 4).value = arr(1) .cells(r, 5).value = arr(2) .cells(r, 6).value = arr(3) .cells(r, 7).value = arr(4) .cells(r, 8).value = arr(5) end end if next c end sub
Comments
Post a Comment