Copy and Paste values from one excel workbook to another -


i tried record macro pasted values of 1 workbook workbook, when "run-time error 9 subscript out of range"

i sure easy fix, , new macros, appreciated. here code:

`sub refresh() ' ' refresh macro ' update xy act. values 2017 ' ' keyboard shortcut: ctrl+r ' windows("xy update file v2.xlsx").activate selection.copy windows("engineering xy chart v2.xlsx").activate activesheet.paste end sub 

its better practice stay away activate , select.

'variables dim workbook1 workbookm, workbook2 workbook, filepath1 string  filepath1 = thisworkbook.path & "\engineering xy chart v2.xlsx" 'assuming filepath same macro workbook filepath2 = thisworkbook.path & "\xy update file v2.xlsx" 'assuming filepath same macro workbook  'make references workbooks set workbook1 = workbook.open(filename:=filepath1) set workbook2 = workbook.open(filename:=filepath2)  'copies cell a1 sheet1 of workbook 2 cell a1 sheet 1 of workbook 1 workbook1.sheets(1).range("a1").value = workbook2.sheets(1).range("a1").value 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -