简体   繁体   English

如何在另一个工作簿中引用一个工作簿以自动打开文件?

[英]How can I reference a workbook within another workbook to automatically open the file?

I have a workbook that contains command buttons to run the macro. 我有一个工作簿,其中包含用于运行宏的命令按钮。 I want the file path for Workbook 3 to be saved in the worksheet underneath the command button in cell B17. 我希望将工作簿3的文件路径保存在工作表中的单元格B17中的命令按钮下方。 I want the macro below to reference that cell and automatically open Workbook 3. The file path will change everyday and I do not want to have to change it in the developer tab. 我希望下面的宏引用该单元格并自动打开Workbook3。文件路径每天都会更改,并且我不需要在“开发人员”选项卡中进行更改。 Please help! 请帮忙!

Sub NCFinal()

Dim Wb1 As Workbook
Dim Wb2 As Workbook
Dim Wb3 As Workbook

With Application
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
End With

Set Wb1 = Workbooks.Open("A:Desktop\Excel Files\Data Template.xlsb")
Set Wb2 = Workbooks.Open("A:Desktop\Excel Files\MarchData.xlsb")
**Set Wb3 = Workbooks.Open(Filename:=Sheets("Sheet1").Range("B17").Value)**
Wb1.Sheets("FRD").Copy After:=Wb2.Sheets("Sheet1")
Wb3.Sheets("CDGL Data").Copy After:=Wb2.Sheets("FRD")

Wb1.Close False
Wb3.Close False
Set Wb3 = Workbooks.Open(Filename:=ThisWorkbook.Sheets("Sheet1").Range("B17").Value)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以在单元格公式内的另一个打开的工作簿中使用另一个打开的工作簿的 VBA 函数吗? - Can I use another open workbook's VBA Functions in another open workbook within a Cell formula? 在另一个Excel工作簿中打开一个Excel工作簿,然后在此工作簿中填写一个公式 - Open an Excel Workbook within another Excel Workbook and then fill a Formular in this workbook VBA我如何打开另一个工作簿? - VBA how do i open another workbook? 如何通过当前工作簿中的单元格内容引用其他工作簿? - How can I refer to another workbook by the content of a cell in the current workbook? 如何将一个工作簿中的一个工作表复制到另一个工作簿中 - how can i copy one worksheet in one workbook into another workbook 如何更快地打开此VBA工作簿? - How can I open this VBA workbook faster? 如何使用VBA打开宏工作簿? - How can I open a macro workbook with VBA? 如何从工作簿B中调用Workbook_Open on Workbook A? - How can I call Workbook_Open on Workbook A from Workbook B? 如何自动将数据输入从一个工作簿复制到另一个工作簿,而无需激活宏或打开工作簿 - How to automatically copy data entry from 1 workbook into another without having to activate macro or open workbook 如何使用工作簿和工作表的变量将数据从一个 Excel 工作簿复制到另一个 Excel 工作簿? - How can I copy data from one Excel workbook to another Excel workbook using variables for Workbook and Worksheet?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM