0

Is there a way to create an array variable with uniform entries without using a loop? For example, to create an array variable with 25 entries I could do the following:

Dim myarray(1 to 25) as String

For n = 1 to 25
    myarray(n) = "Hello"
Next n

This would get the job done, but I am looking for a way to do that in one fell swoop.

3
  • 1
    You mean: Dim vArr As Variant: vArr=Array("one", "two", .. "twenty nine"...) ? Commented Jun 20, 2016 at 15:20
  • Not quite. I'd like it to have all the same value like: Dim vArr as Variant: vArr=Array("one","one", .. "one"...) Commented Jun 20, 2016 at 16:01
  • 2
    Whenever a loop is the most obvious approach it's usually the best approach. If you want to do this multiple times then wrap it up in a function. Commented Jun 20, 2016 at 16:13

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.