title: Excel VBA Resize Table Copying Formulas & Shapes
body: <p>I have a table containing formulas and shapes on every row.</p>
  <p>I want to resize the table based on a user's input from userform (Lets just call the value given TextBox1.Value) The user inputs a new desired table row size into the userform and clicks &quot;OK&quot;</p>
  <p>Let's call the Table Table1, see code below:</p>
  <pre><code>Private Sub UserForm_Initialize()
      Dim ob As ListObject
      Dim count As Integer
      Set ob = Sheets(&quot;Worksheet&quot;).ListObjects(&quot;Table1&quot;)
      count = ob.Range.Rows.count - 1
      TextBox1.value = count
  End Sub
  
  Private Sub OKButton_Click()
      Application.ScreenUpdating = False
      Application.Calculation = xlCalculationManual
      Application.EnableEvents = False
      Dim ob As ListObject
      Dim count As Integer, i As Integer, j As Integer
      Set ob = Sheets(&quot;Worksheet&quot;).ListObjects(&quot;Table1&quot;)
      count = ob.Range.Rows.count - 1
      If TextBox1.value &lt; 2 Then
          Unload Me
      ElseIf TextBox1.value &gt; count Then
          ob.Resize ob.Range.Resize(TextBox1.value + 1)
          ob.ListRows(count).Range.Select
          Selection.AutoFill Destination:=ob.ListRows(count &amp; &quot;:&quot; &amp;_ 
          TextBox1.value).Range,Type:=xlFillDefault
          ob.ListRows(TextBox1).Range.Select
      ElseIf TextBox1.value &lt; count Then
          ob.Range.Rows(TextBox1.value + 1 &amp; &quot;:&quot; &amp; count).Delete
      End If
      Application.CutCopyMode = False
      Unload Me
      Application.ScreenUpdating = True
      Application.Calculation = xlCalculationAutomatic
      Application.EnableEvents = True
  End Sub
  </code></pre>
  <p>My issue is when the user inputs a value greater than the table's current row count.</p>
  <p>The table resizes correctly, but there is an error when copying the rows.</p>
  <p>&quot;Run Time Error 9, Subscript out of Range&quot;</p>
  <p>The desire is to copy down the formulas and shapes to the newly created rows quickly.</p>
  <p>Can anyone see what I'm doing wrong?</p>