Page 72 - Excel et son VBA
P. 72
Code 3
Sub FirstCode( )
Dim FormatCell As Integer
FormatCell = ActiveCell.Value
If FormatCell < 20 Then
With ActiveCell.Font
.Bold = True
.Name = "Arial"
.Size = "16"
End With
End If
End Sub
Code 4
Sub MesBoitesDeDialogue()
Dim prenom As String
prenom = InputBox ("Entrer votre prénom", "Saisie", "")
MsgBox ("Bonjour " & prenom)
End Sub
Code 5
Public Function MaSommeCarre (n As Long) As Double
Dim s As Double, i As Long
For i = 1 To n
s = s + i ^ 2
Next i
MaSommeCarre = s
End Function
69