With Application.FileDialog(msoFileDialogOpen)
.Filters.Clear
.Filters.Add "Excel 2002-03", "*.xls", 1
.Filters.Add "Excel 2007", "*.xlsx; *.xlsm; *.xlsa", 2
.AllowMultiSelect = False
.Show
If .SelectedItems.Count > 0 Then
Workbooks.Open .SelectedItems(1)
Set wkbSourceBook = ActiveWorkbook
Set rngSourceRange = Application.InputBox(prompt:="Select source range", Title:="Source Range", Default:="A1", Type:=8)
wkbCrntWorkBook.Activate
Set rngDestination = Application.InputBox(prompt:="Select destination cell", Title:="Select Destination", Default:="A1", Type:=8)
rngSourceRange.Copy rngDestination
rngDestination.CurrentRegion.EntireColumn.AutoFit
wkbSourceBook.Close False
End If
End With
我正在创建一个对话框,将文件名作为输入,然后需要将完整的工作表复制到另一个工作簿,而不是选择范围和内容。该怎么做
答案 0 :(得分:1)
您可以使用Copy
对象的Worksheet
方法。
wkbSourceBook.Sheets(1).Copy After:=wkbCrntWorkBook.Worksheets(1)
您可以根据名称选择您想要的任何一张纸。它将使用现有名称进行复制,如果已存在则将变为“Name(2)”。然后,您可以从那里重命名它。