Private Sub CommandButton1_Click()
Dim l&, c&
l = TextBox2: c = TextBox1: Cells.Clear
Cells(1, c + 1).Resize(l).FormulaR1C1 = "=SUM(RC[-" & CStr(c) & "]:RC[-1])"
Cells(l + 1, 1).Resize(, c).FormulaR1C1 = "=SUM(R[-" & CStr(l) & "]C:R[-1]C)"
Range(Cells(1, 1), Cells(l, c)).Borders.LineStyle = 1
End Sub