在VBA中加入两个数组? [英] Joining two arrays in vba?

查看:78
本文介绍了在VBA中加入两个数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将这些数组与(2、4、5、3、7、6)的结果组合?

How do I combine these arrays with the outcome of (2, 4, 5, 3, 7, 6)?

array1 = Array(4,5,3,7,6)

array2 = Array(2)

推荐答案

您可能会 Join()并连接两个数组,然后 Split()结果回到新数组:

You could potentially Join() and concatenate your two arrays, and then Split() the result back to a new array:

array3 = Split(Join(array2, ",") & "," & Join(array1, ","), ",")

说明:
Join()将返回一个字符串,该字符串具有数组中的每个元素(第一个参数),以," (第二个参数)分隔.我们用另外一个逗号将这两个连接的数组连接起来,得到像 2,4,5,3,7,6 这样的字符串.然后,我们使用 Split()将字符串转换回一个数组,告诉 Split()斜线除法器是逗号," .

Explanation:
Join() will return a string that has each element in the array (first parameter) delimited by a "," (second parameter). We concatenate those two joined arrays with one more comma to get a string like 2,4,5,3,7,6. We then use Split() to turn that string back into an array telling Split() that the delimter is a comma ",".

这篇关于在VBA中加入两个数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆