简体   繁体   中英

Macro for copying cells from one open workbook to another open workbook…if I dont knwo their file path's

用于将单元格从一个打开的工作簿复制到另一打开的工作簿的宏...如果我不知道其文件路径的PS:该代码将写在源工作簿中

You need something like this ( ThisWorkbook is a reference to Workbook you have the VBA code):

    ThisWorkbook.Worksheets("Sheet1").Range("A1:B2").Copy
    Workbooks("Book1.xslx").Worksheets("Sheet1").Range("A1").Insert Shift:=xlDown

Assuming both workbooks are already opened. You do not need to know the full path - only file name matters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM