excel - Why won't my range paste? -


the following vba code, reason code run not paste in range need paste. have ideas why won't paste values?

the programs goes selected cell i'm looking for, activecell becomes range , i'm trying paste there. information help, doesn't want paste values in range selected.

sub macro1()  dim form1033 worksheet dim cleaningschedule worksheet  set form1033 = worksheets("form1033andform1034") set cleaningschedule = worksheets("cleaningschedule")  dim day range set day = form1033.range("$j$3")  form1033  range("$g$5:$g$18").select selection.copy  end  cleaningschedule  dim integer  = 6 37  if cells(4, i).value = day.value  cells(5, i).select  range(activecell, cells(activecell.rows + 13, activecell.column)).select selection.pastespecial paste:=xlpasteformulas, operation:=xlnone, _         skipblanks:=false, transpose:=false                  end if           next     end   form1033.select application.cutcopymode = false range("$g$5:$g$18").clearcontents  msgbox "scoresheet updated"   end sub 

i fixed code here, please read link provided in comment, , not have these errors in future.

i commented refactors did code. also, notice assigned cells , ranges parent worksheet .. (see @brucewayne's link in comment original question)

sub macro1()  dim form1033 worksheet dim cleaningschedule worksheet  set form1033 = worksheets("form1033andform1034") set cleaningschedule = worksheets("cleaningschedule")  dim day range set day = form1033.range("$j$3")  'copy range directly form1033.range("$g$5:$g$18").copy  cleaningschedule      dim integer      = 6 37          if .cells(4, i).value = day.value              'paste directly range , combined 13 rows plus row 5, since using same row             range(.cells(5,i), cells(18,i)).pastespecial paste:=xlpasteformulas, operation:=xlnone, _                 skipblanks:=false, transpose:=false          end if      next  end  'clear contenst directly form1033.range("$g$5:$g$18").clearcontents  msgbox "scoresheet updated"  end sub 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -