excel - Workbook name as a variable -


been trying google while , can't syntax right question!

basically, @ moment have workbooka.xlsm , code directly references "workbooka.xlsm"

when workbook distributed, not leaves name same , causes subscript out of range errors

the answer obvious, how can declare workbook variable or similar? thisworkbook.name?

my product opens seperate workbook, pulls data , places workbook - worried thisworkbook or similar might cause issues if more 1 open?

sorry silly question, hope can help!

this should work

 option explicit   sub workingwithdatafromotherworkbook()        'you can dim sheet , set sheet            dim masterworkbook workbook       dim datasourceworkbook workbook        set masterworkbook = thisworkbook       'set datasourceworkbook = workbooks.open(filename:=" full file path here")       set datasourceworkbook = workbooks.open(filename:="c:\users\oosthjp\desktop\book1.xlsm")        'simple copy paste code below       datasourceworkbook.sheets("sheetreference").range("somerange").copy       masterworkbook.sheets("sheetreference").range("somerange").paste        'whatever other code have goes here   end sub 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -