复制多个范围和表格

时间:2018-01-10 11:26:15

标签: excel-vba range copying vba excel

我正在尝试将工作簿中的多个范围复制到另一个工作表中。我曾尝试使用MyMultipleRange但仍然收到“object_'Global'的”方法'联盟'的消息失败。

Function WorkbookName() As String
    WorkbookName = ThisWorkbook.Name
End Function

Sub dataimport()
    Dim i As Integer
    Dim Data

    Workbooks(WorkbookName).Activate
    Sheets("Input").Select
    Datapath = Cells(15, 4)
    Data = Cells(15, 3)

    Application.Workbooks.Open (Datapath)

    Dim r1, r2, myMultipleRange As Range
    Set r1 = Sheets("Sheet1").Range("A1:Ak518")
    Set r2 = Sheets("Sheet2").Range("B2:J10")
    Set myMultipleRange = Union(r1, r2)

    Workbooks(WorkbookName).Activate
    Sheets("Sheet5").Select
    Range("A1:Ak600").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False


     Workbooks(Data).Close savechanges:=False

End Sub

1 个答案:

答案 0 :(得分:0)

我认为这会做你想要的。

sage.combinat.posets.posets.FinitePoset