title: Assigning values to array vba
body: <p>I don't have experience using arrays in VBA and I got lost. What I try to do is the following:</p>
  
  <p>In the column A I have ~15 strings (number is not fixed sometimes it is more sometimes less)</p>
  
  <p>I remove duplicates and then for each name in the column A I would like to create separate sheet in the file. </p>
  
  <p>I created an array to which I tried to assign each name from A with this loop:</p>
  
  <pre><code>Sub assigningvalues()
  
  Dim i As Integer
  Dim myArray(20) As Variant
  Dim finalrow As Long
  
  ActiveSheet.Range("A1", Range("A1").End(xlDown)).RemoveDuplicates Columns:=Array(1)
  
  finalrow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlDown).Row
  
  'For i = 2 To finalrow -&gt; I get overflow error when I use this range   
  For i = 2 To Cells(20, 1)  
      myArray(i) = Cells(i, 1).Value    
  Next i
  
  'I check with the lines below if values were assigned    
  Cells(2, 4).Value = myArray(4)
  Cells(3, 4).Value = myArray(2)
  
  End Sub
  </code></pre>
  
  <p>Nevertheless values from the cells to do not assign to the array</p>
  
  <p>Moreover when I try to use <code>finalrow</code> as range for the loop I get overflow error (It is not a big problem as there are workarounds, although it would be nice to know what I've done wrong)</p>