View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
John Baker John Baker is offline
external usenet poster
 
Posts: 98
Default Reference to a variable in windows(???).Activate

FranK;

Thank you very much for the useful response. It works finer EXCEPT for the last line:
target_wks.paste

Somehow it appears to want other parameters (range "C5:D7"perhaps) , and I am not certain
how to set them up. You advice would be appreciated.

Thanks

John Baker


"Frank Kabel" wrote:

Hi John
in general no need for using Select statements or the names of the
workbooks. Use object references. e.g. try something like

sub foo()
dim source_wbk as workbook
dim source_wks as worksheet
dim target_wkb as workbook
dim target_wks as worksheet
dim installfile

installfile = installpath &/& installname 'adapt to your needs
set target_wbk = activeworkbook
set target_wks = target_wbk.worksheets("Input")
workbooks.open installfile
set source_wbk = activeworkbook
set source_wks=source_wbk.worksheets("Input")

source_wks.range("C5:D7").copy
target_wks.paste
end sub