excel - Error in copying range using inputboxes from one sheet to anoyher -


i have been trying copy defined range through input-box defined range through input-box on other sheet. getting error run-time error "'1004' application define or object defined error". on line

          rngcopyfrom.copy thisworkbook.sheets("sheet2").range("rngcopyto") 

my level beginner. please guide me in way change serve desired objective.

 sub sample()   dim rngcopyfrom range   dim rngcopyto range   on error resume next     set rngcopyfrom = application.inputbox("enter range  ant copy", type:=8) on error goto 0  on error resume next      set rngcopyto = application.inputbox("enter range             want copy", type:=8) on error goto 0  if not rngcopyfrom nothing     '~~> copy range shhet2     rngcopyfrom.copy thisworkbook.sheets("sheet2").range("rngcopyto") end if end sub 

this program works if define fixed range shown in line below.

           rngcopyfrom.copy thisworkbook.sheets("sheet2").range("d2:d14") 

this should work 2 input boxes:

option explicit  sub copyrangefrominputboxes()      dim copyfrom range, copyto range      err.clear     on error resume next            'if input cancelled      set copyfrom = application.inputbox("select source range", type:=8)      if not copyfrom nothing 'if not cancelled          set copyto = application.inputbox("select destination range", type:=8)          if not copyto nothing copyfrom.copy copyto      end if  end sub 

the code copy sheet , paste on other sheet:

enter image description here


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -