title: Excel VBA: How do I change font size and alignment inside text boxes
body: <p>I have created a grid of text boxes, but I cannot figure out a method to change the font size and alignment (centralise vertically and horizonatally) of the text inside a named textbox.</p>
  
  <pre><code>Sub addtxtbx()
  Dim shp As Shape
  Dim i As Integer, j As Integer, k As Integer
  Dim cindx as long, rindx as long
  For i = 1 To 145
  Set shp = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, _
              100 + cindx, 100 + rindx, 50, 50)
      cindx = (i - Int((i - 1) / 4) * 4 - 1) * 50 + Int((i - 1) / 48) * 200
      rindx = (Int((i - 1) / 4) - Int((i - 1) / 48) * 12) * 50
      With shp
          .Name = "TxtBx" &amp; (i - 1)
           .Fill.ForeColor.RGB = RGB(204, 102, 255)
      End With
  Next i
  
  With ActiveSheet.Shapes.Range(Array("TxtBx11")).TextFrame2.TextRange
      .Characters.Text = "R"
  End With
  End Sub
  </code></pre>
  
  <p>Also, I have been scratching my head with the For Next loop's i counter. I used it to rename the text boxes and found that despite using i = 1 to 144, TxtBx144 is not the last box, but the second last, TxtBx2 is the first. So, I tried to get around it by using 1 to 145 and name the box using (i-1) serial which is a bit of a cop out. What did I do wrong that I am failing to see?</p>