Split function vba -
i attempting take user input , split each bit of input using comma. trying use -
includer = cstr(inputbox("do have inclusions? separate words commas")) inclusion = split(includer, ",", , vbtextcompare)
with no luck.
it keeps throwing 'type mismatch' error.
the full code attempting use, interested, is-
option compare text public sub textchecker() ' ' textchecker ' ' keyboard shortcut: ctrl+h ' dim continue long dim findwhat string dim lastline long dim tocopy boolean dim cell range dim item long dim j long dim x long dim sheetindex long dim inclusion() string sheetindex = 2 continue = vbyes while continue = vbyes findwhat = cstr(inputbox("what word search today?")) includer = cstr(inputbox("do have inclusions? separate words commas")) inclusion = split(includer, ",", , vbtextcompare) lastline = activesheet.usedrange.rows.count if findwhat = "" exit sub j = 1 item = 1 lastline each cell in range("by1").offset(item - 1, 0) if instr(cell.text, findwhat) <> 0 , instr(cell.text, inclusion(x)) <> 0 tocopy = true end if next if tocopy = true sheets(sheetindex).name = ucase(findwhat) + "+" + lcase(inclusion(x)) rows(item).copy destination:=sheets(sheetindex).rows(j) j = j + 1 end if tocopy = false next item sheetindex = sheetindex + 1 continue = msgbox(((j - 1) & " results copied, have more keywords enter?"), vbyesno + vbquestion) loop end sub
change
dim inclusion string
to
dim inclusion() string 'recommended in opinion
or
dim inclusion variant
edit
i see use of inclusion later in code. looks need iterate on new array.
dim x long 'put @ top, rename you'd like. x = lbound(inclusion) ubound(inclusion) 'do stuff inclusion(x), other code here before i'm not sure right anymore. next
edit 2
item = 1 lastline if ubound(insulation) >= 0 'write procedure when inclusion present else 'write 2nd procedure when inclusions not present end if next item
Comments
Post a Comment