最快的方法来读取一列数字到数组中 [英] Fastest way to read a column of numbers into an array

查看:181
本文介绍了最快的方法来读取一列数字到数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说如果我有一列数字(其中有几个可能有所不同,但可能在1000-10000之间),我想将它们全部读入VBA中的数组,最快的做法是什么所以?



显然,我可以创建一个大小为10000的数组,并为/ while循环创建一个,但是有什么方法比这更快吗?



  Dim Ar as Variant 

Ar = Sheets(Sheet)。Range(A1:A10000)。value

如果您不知道最后一行,则可以使用这个,然后使用上面的代码作为

  Ar = Sheets(Sheet)。Range A1:A& LRow).Value 


Say if I have a column of numbers (how many of them could vary, but could be anywhere between 1000-10000) and I would like to read all of them into an array in VBA, what is the fastest way of doing so?

Obviously I can create an array of size 10000 and do a for/while-loop but is there any way that's faster than this?

解决方案

Like this?

Dim Ar as Variant

Ar = Sheets("Sheet").Range("A1:A10000").Value

If you do not know the last row then you can find the last row using this and then use the above code as

Ar = Sheets("Sheet").Range("A1:A" & LRow).Value

这篇关于最快的方法来读取一列数字到数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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