excel - Code Skipping Second Cell, Not Supposed To -
this code part of bigger code takes words listbox , places listbox, code separates words in listbox , establishes words able inserted cell, reason second strsplt
not showing, else working well, it's one, need , there no error thrown out. i've looked on f8 , breakpoints , problem seems
if ii < .columncount - 1 str = str & .list(i, ii) & vbcrlf else str = str & .list(i, ii) end if
the whole code:
with me.selecteditems thisworkbook.sheets(9).range("a:b").clearcontents = 0 .listcount - 1 if .selected(i) found = true ii = 0 .columncount - 1 redim strsplt(0 i) if str = "" str = .list(i, ii) & vbcrlf else if ii < .columncount - 1 str = str & .list(i, ii) & vbcrlf else str = str & .list(i, ii) end if end if next ii message = "how much" & vbcrlf & str & "?" & vbcrlf title = "amount" defaultval = "1" quantity = inputbox(message, title, defaultval) strsplt = split(str, "*") end if 'on error resume next thisworkbook.sheets(9) .range("a" & (i + 1)).value = strsplt(i) .range("b" & (i + 1)).value = quantity end 'on error goto 0 next end
edit: way looks using debug.print str
- item1
- item2 item3 item4 ...
try bit brute forcing this:
if ii < .columncount - 1 str = str & .list(i+1, ii) & vbcrlf else str = str & .list(i+1, ii) end if
i have changed i
i+1
in code. debug again. if not work, try i-1
, ii+1
, ii-1
. 1 of these work , may give out of range error. fix array length , have fun.
Comments
Post a Comment