title: Repeat a Number N Times in an Array
body: <p>Working with Excel VBA.</p>
  
  <p>I'm trying to create an array with repetitive patterns like this:</p>
  
  <pre><code>a = Array(1,1,1,1,1,2,2,2,2,2,2)
  </code></pre>
  
  <p>Is there a neat solution (without going through a loop) to do this? In almost any other statistical language this is done with a repeat function. For example the "rep" function in R or the "repmat" fuction in Matlab:</p>
  
  <pre><code>a = [repmat(1,1,5),repmat(2,1,6)]
  </code></pre>
  
  <p>The reason not to hard-code everything in the first place is because the actual array has varying length depending on some other variables.</p>