我的问题与其他问题相似,但不完全相同。解决方法的重点是使原始文件保持完整。
我有文件A和B。A中的宏必须:
这是否可行,还是应该以其他方式解决?
答案 0 :(得分:0)
有关如何在另一个工作簿中编辑单元格并将其复制到该工作簿中的基本示例:
'open another workbook
Dim wbB As Workbook
Set wbB = Workbooks.Open(FileName:="C:\Temp\WorkbookB.xlsx", ReadOnly:=True)
'change something in that other workbook
wbB.Worksheets("SheetInWorkbookB").Range("A1").Value = "I changed it"
'copy from that other workbook into this workbook
wbB.Worksheets("SheetInWorkbookB").Range("A1:A10").Copy Destination:=ThisWorkbook.Worksheets("Result").Range("A1")
'close that other workbook without saving
wbB.Close SaveChanges:=False