Excel VB Scripting Error Handling - "object variable or with block not set" Error -
Excel VB Scripting Error Handling - "object variable or with block not set" Error -
i'm having problem macro excel. snippet that's giving me problem responsible for:
1) allowing user select multiple column headers, 1 1 2) taking contents of each columns, in order of header selection, , concatenating
here's code:
dim concat1() range dim rng variant dim variant dim g integer dim metalabels() string dim concated string dim s variant lastrow = cells(rows.count, "a").end(xlup).row = 0 msgselect = msgbox("would concatonate?", vbokcancel) on error goto errhandler if msgselect = vbok redim preserve concat1(i) set concat1(i) = application.inputbox("select headers concatonate", default:=activecell.address, type:=8) msgselect = msgbox("another cell?", vbokcancel) = + 1 loop while msgselect = vbok = - 1 errhandler: end if redim metalabels(i) g = 0 metalabels(g) = concat1(g).text next activesheet.range("a1").end(xltoright).offset(0, 1).select activecell = "situation" h = 1 lastrow - 1 g = 0 ubound(metalabels) concated = concated + metalabels(g) + ": " + concat1(g).offset(h, 0).text + " / " next activecell.offset(h, 0).value = concated concated = "" next end sub
the problem here:
set concat1(i) = application.inputbox("select headers concatonate", default:=activecell.address, type:=8)
if user selects "cancel," code crashes since loop depends on vbok. so, thought i'd set in error handler, but, is, "object variable or block not set" error.
as might sense, i'm still nube vb. help appreciated.
thanks!
did seek adding if concat1(i) = false exit sub
before incrementing i?
excel excel-vba vbscript
Comments
Post a Comment