Sub aaa()
Randomize Timer
n = InputBox("Количество строк (колонок)")
ReDim a(1 To n, 1 To n) As Double
For i = 1 To n
a(i, i) = i * (i + 1)
Next i
Cells.Clear
Dim r As Range
Set r = Range(Cells(2, 2), Cells(n + 1, n + 1))
r = a
r.Borders.Weight = xlThin
r.BorderAround Weight:=xlMedium
End Sub