声明变量 [英] Declaring Variables
问题描述
您好
有人可以帮我解决这个问题。我正在开发一个excel vba宏。我有一些数据 进行排序,然后根据Excel工作表提供的一些值对其进行分组。例如,
让我们说,我有两个组值红色和蓝色。
所以对于,Red我要声明一个变量'strRed'和Blue我想声明一个变量'strBlue'。
这里组的数量是两个所以它很简单我可以直接在我的代码中使用这两个变量。但实际上这个数字是未知的,它可以是4(也可以说是黄色和绿色)。
在这种情况下如何在运行时声明另外两个变量,如果可能的话名称为'strYellow'和'strGreen'。
我知道For循环不会以这种方式工作。
intNoofGroups = 4
对于i = 1到 intNoofGroups
Dim<声明变量但是>
下一步
非常感谢任何建议。
  ;
谢谢
Maneesh Agarwal
虽然它没有真正受到限制,但你在这个论坛上几乎没有机会得到真正的好答案。
这个论坛是由Visual Basic Net开发人员填充的,而不是VBA开发人员。
为VBA尝试一个论坛或新闻组,在那里你有更多的机会获得好的答案。
(也可以在这里,不被禁止)
Hi
Can somebody help me on this. I am developing an excel vba macro. I have some set of data to sort and then group it based on some values provided from the excel sheet. for eg.,
Lets say, I have two group values Red and Blue.
So for, Red I want to declare a variable 'strRed' and for Blue I want to declare a variable 'strBlue'.
Here the number of groups is two so its simple I can directly these two variables in my code. But actually this number is not known and it can be 4 (lets say Yellow and Green also).
In that case how can I declare two more variables on the run time and if possible with names as 'strYellow' and 'strGreen'.
I know For loop wont work this way.
intNoofGroups=4
For i = 1 to intNoofGroups
Dim <declare variable but how>
Next
Any sort of advise is greatly appreciated.
Thanks
Maneesh Agarwal
Although it is not really restricted, do you have few chance on a real good answer in this forum.
This forum is populated with Visual Basic Net developers, not with VBA developers.
Try a forum or newsgroup for VBA, where you have more chance on good answers.
(Can be here as well, it is not forbidden)
这篇关于声明变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!