1
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

我正在创建一个对话框以将文件名作为输入,然后需要将完整的工作表复制到另一个工作簿,而不是选择范围和内容。怎么做

4

1 回答 1

1

您可以使用对象的Copy方法Worksheet

wkbSourceBook.Sheets(1).Copy After:=wkbCrntWorkBook.Worksheets(1)

您可以按名称选择您想要的任何表格。它将使用现有名称进行复制,如果已存在将变为“名称(2)”。然后,您可以从那里重命名它。

于 2012-08-02T10:59:35.880 回答