Cell adressing

Private Sub CommandButton1_Click()
' Do the Calculation

Dim i, j, n As Integer
Dim sum As Double
' Get n values from A10..A30
' These are cells (1,10) to (1,30)
' Place the results in cells (2,10) to (2,30) for n^2
' And in (3.10)..(3.30) for n^3
' I try to remember A_rc   ('arc') for row and column subscripts

For i = 10 To 30
n = Cells(i, 1).Value
Cells(i, 2) = n ^ 2
Cells(i, 3) = n ^ 3
Next i

' Now to get cells e10 and f10, calculate and put back in g10, etc
For i = 10 To 20
sum = Cells(i, 5).Value
j = Cells(i, 6).Value
Cells(i, 7).Value = sum ^ j
Next i

End Sub

=====================================================
Private Sub CommandButton1_Click()
' Do the Calculation

Dim i, j, n As Integer
Dim sum As Double
' Hybrid formatting illustrated

For i = 10 To 30
n = Range("A" & Format(i)).Value
Range("B" & Format(i)) = n ^ 2
Range("C" & Format(i)).Value = n ^ 3
Next i

' Now to get cells e10 and f10, calculate and put back in g10, etc
For i = 10 To 20
sum = Range("E" & Format(i)).Value
j = Range("F" & Format(i)).Value
Range("G" & Format(i)).Value = sum ^ j
Next i

End Sub

=======================================

Private Sub CommandButton1_Click()
' Calculate the integral
Dim i, power, NrSteps As Integer
Dim dtheta, sum As Double

'This is a very simple rectangular-type integration
' We use the value halfway along in the step

power = Range("Power").Value
NrSteps = Range("Steps").Value
dtheta = 3.14159265 / NrSteps

sum = 0
For i = 1 To NrSteps
sum = sum + Sin((i - 0.5) * dtheta) ^ (power)
Next i
sum = sum * dtheta
Range("Integral") = sum
End Sub