Prompt User to open another workbook

后端 未结 1 1038
日久生厌
日久生厌 2021-01-27 23:29

I am writing a sub, where I need the user to open a specific workbook, because I need to copy data from the workbook that will be opened, to the workbook that is running the sub

相关标签:
1条回答
  • 2021-01-27 23:55
    Function openMontlyReport() as Workbook
       MsgBox "Please select the monthly report in the next file dialog"
       With Application.FileDialog(msoFileDialogOpen)
         .Title = "Select Monthly Report"
         .Filters.Add "Excel Files", "*.*"
         .AllowMultiSelect = False
         If .Show Then Set openMontlyReport = Application.Workbooks.Open .SelectedItems(1)
       End With
    End Function
    

    Now you have at hand the monthly workbook that the user just opened.

    0 讨论(0)
提交回复
热议问题