我有一个工作簿,其中包含用于运行宏的命令按钮。我希望将工作簿3的文件路径保存在单元格B17中命令按钮下面的工作表中。我希望下面的宏引用该单元格并自动打开工作簿3.文件路径将每天更改,我不想在开发人员选项卡中更改它。请帮忙!
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
答案 0 :(得分:2)
Set Wb3 = Workbooks.Open(Filename:=ThisWorkbook.Sheets("Sheet1").Range("B17").Value)