excel vba - how do I get my macro to automatically copy data from range of one book to another range in book 2 -


this second day using vba , excel.i'd macro automatically copy values woksheet "consulting-for paracon_aax.xls" range "e24"to "q24" , paste values worksheet named "2014 - xpert.xlsm" on range "e9-q9" in sheet named delivery.this i've come far.

sub updatelinks()  'open source workbook , select source sheet workbooks.open filename:="c:\users\desmondm\desktop\consulting-for paracon_aax.xls"  sheets("sheet1").select  ' copy source range  sheets("sheet1").range("e24").select  selection.copy  ' select current workbook , paste value @ e9 workbooks("2014 - xpert.xlsm").activate  sheets("delivery").select  sheets("delivery").range("e9").select  activesheet.paste  application.cutcopymode = false  activeworkbook.save  end sub 

but problem code macro copies cell e24 consulting-for paracon_aax.xls e9 in delivery sheet within 2014 - xpert.xlsm wokbook.i'm stuck @ trying make macro copy e24 q24 in 1 book , paste values e9 q9 in other workbook on delivery sheet.

give try, consolidated bit you, need specify full range of cells copy (previously copying e24.

sub updatelinks() dim wbsource workbook dim wbdestination workbook  'open source workbook , select source sheet set wbsource = workbooks.open( _     filename:="c:\users\desmondm\desktop\consulting-for paracon_aax.xls")  'set destition workbook variable set wbdestination = workbooks("2014 - xpert.xlsm")  'copy source range wbsource.sheets("sheet1").range("e24:q24").copy  'paste value @ e9 wbdestination.sheets("delivery").range("e9:q9").pastespecial (xlpastevalues)  application.cutcopymode = false  activeworkbook.save  end sub 

and, word wise :) tempting use select , activate methods -- when new vba, because how macro recorder captures actions, 99% of time these unnecessary, , it's more efficient/better use object variables , explicitly refer them, rather relying on selection , activeworkbook or activecell, etc.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -