小编Phi*_*_PK的帖子

VBA将多个范围复制到阵列 - 无循环

我想将分离范围内的数据复制到没有loopnig的数组中.以下方法不起作用,因为它只使用来自rng1的数据填充数组.任何建议我如何做到这一点?

Dim rng1 As Range, rng2 As Range, rng3 As Range, rngMerge As Range
Dim tmpMatrixCPs_CDS() As Variant

Set WS_Ins_Mapping = ThisWorkbook.Worksheets("Instrumente_Mapping")
LastRow = WS_Ins_Mapping.Cells(rows.Count, 2).End(xlUp).Row
Set rng1 = WS_Ins_Mapping.Range(WS_Ins_Mapping.Cells(6, 2), WS_Ins_Mapping.Cells(LastRow, 2))
Set rng2 = WS_Ins_Mapping.Range(WS_Ins_Mapping.Cells(6, 26), WS_Ins_Mapping.Cells(LastRow, 26))
Set rng3 = WS_Ins_Mapping.Range(WS_Ins_Mapping.Cells(6, 36), WS_Ins_Mapping.Cells(LastRow, 36))
Set rngMerge = Union(rng1, rng2, rng3)
tmpMatrixCPs_CDS = WS_Ins_Mapping.Range(rngMerge).Value
Run Code Online (Sandbox Code Playgroud)

提前谢谢了

excel vba excel-vba

3
推荐指数
1
解决办法
2503
查看次数

标签 统计

excel ×1

excel-vba ×1

vba ×1