使用for循环来调用VBA中的连续变量名(即car1,car2 .... car10) [英] Using a for loop to call consecutive variable names (ie car1, car2.... car10) in VBA

查看:584
本文介绍了使用for循环来调用VBA中的连续变量名(即car1,car2 .... car10)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景)
我有七个变量; labelKid1,labelKid2,... LabelKid3。我正在搜索通过单元格找到不是空的,然后从labelKid1开始输入该值,然后移动到下一个标签。

Scenario) I have seven variables; labelKid1, labelKid2, ...LabelKid3. I'm searching through cells to find ones that are not empty, and then entering the value into the label, starting with labelKid1, and then moving on to the next label.

问题)
有没有办法给我们一个for循环来看这些变量?这样我可以用某种方式调用变量,例如labelKid + j,其中j是for循环的值?这样可以让我更容易地进入标签。

Question) Is there a way to us a for loop to go through these variables? By this I mean can I somehow call the variable with something such as labelKid + j , with j being the value of the for loop? This would allow me to march through the labels a lot more easily.

现在,我明白,我可以通过将标签放入数组中并使用循环调用他们的指标,但是有没有办法像上面所说的那样?

Now, I understand that I could probably do this by putting the labels into an array and using a for loop to call their indicies, but is there a way to do it as I stated above?

推荐答案

不,VBA不支持变量变量(在PHP中调用)。正如你所说,你将需要使用列表,字典或类似的。

No, VBA does not support variable variables (as they are called in PHP). As you said you will need to use a list, dictionary or similar instead.

这篇关于使用for循环来调用VBA中的连续变量名(即car1,car2 .... car10)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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