excel - Remove object required message in cancel option of inputbox -


is there way remove error message(object required message) pops out input box whenever user presses cancel button?

sub workingduofunctioncode()      dim rng range, inp range      'to remove 0 values may result of formula or direct entry.      set inp = selection     inp.interior.colorindex = 37     set rng = application.inputbox("copy to", type:=8)     rng.parent.activate     rng.select     inp.copy     worksheets("sheet2").paste link:=true      each cell in range("a1:cl9935")        if cell.value = "0" cell.clear     next  end sub 

not quite sure why using inputbox, don't use in code.

this should take care of errors.

sub workingduofunctioncode()      dim rng range, inp range      'to remove 0 values may result of formula or direct entry.     set rng = nothing     set inp = selection     inp.interior.colorindex = 37     on error resume next     set rng = application.inputbox("copy to", type:=8)     on error goto 0     if typename(rng) <> "range"         msgbox "cancelled...", vbinformation         exit sub     else         rng.parent.activate         rng.select         inp.copy         worksheets("sheet2").paste link:=true     end if     each cell in range("a1:cl9935")         if cell.value = "0" cell.clear     next     application.cutcopymode = 0  end sub 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -