1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| Private Sub CommandButton1_Click()
Dim i As Byte, n As Byte, k As Byte, a As Byte, f As Double
Range("A10:A32").Select
Selection.ClearContents
Range("C10:C32").Select
Selection.ClearContents
Range("E10:E33").Select
Selection.ClearContents
Range("G10:G33").Select
Selection.ClearContents
Range("A8,C8,E8,G8").Select
Range("G8").Activate
Selection.ClearContents
k = Cells(3, 7)
n = Cells(3, 2)
' calcul S1 S2 S3
For i = 1 To n
Cells(9 + i, 1) = k + i - 1
Cells(9 + i, 3) = (k + i - 1) * (k + i - 1)
Cells(9 + i, 5) = (k + i - 1) * (k + i - 1) * (k + i - 1)
Next i
' Calcul de factorielle
For k = k To n + k - 1
a = 1
f = 1
For i = 1 To k
f = f * i
Next i
Cells((9 + k), 7) = f
Next k
' Calcul des sommes S1, S2, S3, SFact
Range("A8").Value = Application.Sum(Range("A10").EntireColumn)
Range("C8").Value = Application.Sum(Range("C10").EntireColumn)
Range("E8").Value = Application.Sum(Range("E10").EntireColumn)
Range("G8").Value = Application.Sum(Range("G10").EntireColumn)
End Sub |
Partager