title: Excel VBA - Subscript out of range
body: <p>I need help. The below code is written to add to column data and store in another column. When I execute the code it says subscript out of range in for loop where it adds to array values.</p>
  
  <p>Kindly give an advice.</p>
  
  <p>Thanks</p>
  
  <pre><code>Sub test()
  
      Dim W1, W2, R1, R2, R3, R4, R5 As Double
      Dim i, j, T As Integer
      Dim myRange As Double
      Dim Arr1 As Variant, Arr2 As Variant, Arr3 As Variant
  
      myRange1 = Worksheets("Sheet2").Range("M15", "M30")
      myRange2 = Worksheets("Sheet2").Range("N15", "N30")
      R1 = WorksheetFunction.Sum(myRange1)
      R2 = WorksheetFunction.Sum(myRange2)
      R3 = (R1 + R2)
      R4 = (R1 / R3) * 100
      R5 = (R2 / R3) * 100
      Range("M31") = R4
      Range("N31") = R5
      Arr1 = Range("M15:M30").Value
      Arr2 = Range("N15:N30").Value
  
      For i = LBound(Arr1) To UBound(Arr1)
          Arr3(i) = Arr1(i) + Arr2(i)
      Next
  
      T = 16
      For j = 1 To T
          Range("M" &amp; 33 + j).Cells = Arr3
      Next
  
  End Sub
  </code></pre>