title: Receiving Error when trying to run macro on multiple sheets using VBA
body: <p>I have the below macro that should be running on each sheet in my workbook. When I run this code, I am getting the following error: 'A table cannot overlap another table' and it is highlighting this line:</p>
  <pre><code>        ActiveSheet.ListObjects.Add(xlSrcRange, Range(&quot;$A:$I&quot;), , xlYes).Name = _
              &quot;Table1&quot;
  </code></pre>
  <p>Is this because I applied the macro to table one and now it cannot be applied to the other tables?</p>
  <p>All sheets have the same column headers but different number of rows (not sure if that matters). Essentially all I am trying to do is get rid of the index, format the data into a table, extend the column lengths to fit all the column names, and rename the columns.</p>
  <p>Another thing to note, there are about 170 sheets that this macro needs to run through.</p>
  <pre><code>Sub forEachWs()
      Dim ws As Worksheet
      For Each ws In ActiveWorkbook.Worksheets
          Call CreateTables(ws)
      Next
  End Sub
  
  
  Sub CreateTables(ws As Worksheet)
  '
  ' CreateTables Macro
  '
  ' Keyboard Shortcut: Ctrl+Shift+S
  '
      With ws
          Columns(&quot;A:A&quot;).Select
          Selection.Delete Shift:=xlToLeft
          Columns(&quot;A:I&quot;).Select
          Application.CutCopyMode = False
          ActiveSheet.ListObjects.Add(xlSrcRange, Range(&quot;$A:$I&quot;), , xlYes).Name = _
              &quot;Table1&quot;
          Columns(&quot;A:I&quot;).Select
          ActiveSheet.ListObjects(&quot;Table1&quot;).TableStyle = &quot;TableStyleLight1&quot;
          Columns(&quot;A:I&quot;).EntireColumn.AutoFit
          Range(&quot;Table1[[#Headers],[Tier2_ID]]&quot;).Select
          ActiveCell.FormulaR1C1 = &quot;Community ID&quot;
          Range(&quot;Table1[[#Headers],[Tier2_Name]]&quot;).Select
          ActiveCell.FormulaR1C1 = &quot;Community Name&quot;
          Range(&quot;Table1[[#Headers],[Current_MBI]]&quot;).Select
          ActiveCell.FormulaR1C1 = &quot;Current MBI&quot;
          Range(&quot;Table1[[#Headers],[countMBI]]&quot;).Select
          ActiveCell.FormulaR1C1 = &quot;Cout&quot;
          Range(&quot;Table1[[#Headers],[Cout]]&quot;).Select
          ActiveCell.FormulaR1C1 = &quot;Count&quot;
          Range(&quot;Table1[[#Headers],[TotalEDVisits]]&quot;).Select
          ActiveCell.FormulaR1C1 = &quot;Total ED Visits&quot;
          Range(&quot;Table1[[#Headers],[EDtoIPTotal]]&quot;).Select
          ActiveCell.FormulaR1C1 = &quot;Total ED to Inpatient&quot;
          Range(&quot;Table1[[#Headers],[totalSev1to3]]&quot;).Select
          ActiveCell.FormulaR1C1 = &quot;Severity 1 to 3&quot;
          Range(&quot;Table1[[#Headers],[totalSev4to6]]&quot;).Select
          ActiveCell.FormulaR1C1 = &quot;Severity 4 to 6&quot;
          Range(&quot;Table1[[#Headers],[totalPaid]]&quot;).Select
          ActiveCell.FormulaR1C1 = &quot;Total Paid&quot;
          Range(&quot;L22&quot;).Select
      End With
  End Sub
  </code></pre>