Naming an array using a variable

后端 未结 2 1959
温柔的废话
温柔的废话 2021-01-27 07:45

Is it possible to name an array variable using a different variable? For example, if I define variable \"i\" as an integer with a value equal to the number of columns I\'ve use

2条回答
  •  星月不相逢
    2021-01-27 08:09

    Yes.

    Dim i(5) As Integer
    

    In VBA you can then access elements from i(0) to i(5).


    Based on your edited question, the answer is no. You must explicitly define each variable in your code.

    The other option would be to write code that writes your code - a form of code generation. Effectively that lets you write very long and complex code by repeating code "templates". But I don't think this would help in your case.

提交回复
热议问题