范围的联合不按顺序

我试图以特定顺序复制各种范围,并将其从工作簿粘贴到不同的工作簿中。

目前

我已经设定了我的范围,例如

Set rg = ws1.Range("A2:A" & i).Offset(rowOffset:=1, columnOffset:=0) Set rg1 = ws1.Range("Z2:Z" & i).Offset(rowOffset:=1, columnOffset:=0) Set rg2 = ws1.Range("C2:C" & i).Offset(rowOffset:=1, columnOffset:=0) Set TradesCopy = Union(rg, rg1, rg2) 

所以通常应该发生的是它应该按照这个顺序粘贴在这些范围内(rg,rg1,rg2),

但是这是粘贴rg,rg2,rg1

谁能告诉我,我能做些什么来解决这个问题?

如果按照需要的顺序从工作表中创build值的二维数组,则可以将它们按任意顺序放置,并且它将比多个“复制和粘贴”操作更快。

 Sub wqewqteq() Dim a As Long, b As Long, c As Long, lr As Long Dim vCOLs As Variant, vVALs As Variant, vSRCs As Variant vCOLs = Array(1, 26, 3) 'could also be Array("A", "Z", "C") With Worksheets("Sheet8") lr = Application.Max(.Cells(.Rows.Count, "A").End(xlUp).Row, _ .Cells(.Rows.Count, "C").End(xlUp).Row, _ .Cells(.Rows.Count, "Z").End(xlUp).Row) vSRCs = .Range(.Cells(2, "A"), .Cells(lr, "Z")).Value2 ReDim vVALs(1 To lr - 1, 1 To UBound(vCOLs) + 1) For a = 1 To lr - 1 For b = LBound(vCOLs) To UBound(vCOLs) vVALs(a, b + 1) = vSRCs(a, vCOLs(b)) Next b Next a .Cells(2, "AB").Resize(UBound(vVALs, 1), UBound(vVALs, 2)) = vVALs End With End Sub 

我找不到特定的目的地,所以我在同一张工作表上使用了AB2。

请记住,您正在处理一维和二维arrays。 一维数组的默认值为零(lbound(vCOLs)== 0); 二维数组的默认值为每个等级的下限(lbound(vVALs,1)== lbound(vVALs,2)== 1)。