title: Excel Table : add blank columns and headers vba
body: <p>I have an excel table and I want to add a column to it and then name the header. Somehow my old codes don't work anymore, and I am not sure if it has anything to do with me making the data range a table (Name is Table1). Now the codes run through with no error but only add the blank column but did not add a header. I pressed <strong>F8</strong> and it looks like it skips Select portion and jumps to the end.</p>
  
  <p>Table is specified from column A to column AG. I used to be able to insert multiple blank columns and add the headers just fine. Now I don't want to specify cell position and assign a cell value to it (<code>cell(1, 32).value ="Month"</code>) since I want to have the flexibility to be add however many columns I need and add the header respectively like before. </p>
  
  <pre><code>Sub Ins_Blank_Cols_Add_Headers()
   Columns("AF:AG").Insert Shift:=xlToRight
   Columns("AF:AF").Cells(1, 1) = "&lt;&lt;NewHeader&gt;&gt;"
   Columns("AG:AG").Cells(1, 1) = "&lt;&lt;NewHeader&gt;&gt;"
      Dim cnter As Integer
  
  LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
  cnter = 0
  
  For i = 1 To LastCol
    If Cells(1, i) Like "&lt;&lt;NewHeader&gt;&gt;*" Then
          Select Case cnter
              Case 0: Cells(1, i).Value = "Month"
              Case 1: Cells(1, i).Value = "Year"
          End Select
          cnter = cnter + 1
      End If
  Next i
  </code></pre>
  
  <p>End Sub</p>