If (expression) Then
stmt
End If
If (expression) Then
stmt
Else
stmt
End If
If (expression) Then
stmt
ElseIf (expression) Then
stmt
Else
stmt
End If
Sub Psyc()
Dim red As Integer
Dim green As Integer
Dim blue As Integer
red = Rnd() * 255
green = Rnd() * 255
blue = Rnd() * 255
Selection.Font.color = RGB(red, green, blue)
End Sub
blue = Rnd() * 255
msg = "red " & red & " green " & green & " blue " & blue
MsgBox (msg)
Selection.Font.color = RGB(red, green, blue)
Sub Funky()
If (Typename(Selection) = "Range") Then
For Each cell In Selection
cell.Font.color = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
cell.value = Int(Rnd() * 50)
Next cell
End If
End Sub
Sub Fact()
Sum = 0
prev = 1
tail = 1
For i = 0 To ActiveCell.Value
tail = prev
prev = Sum
Sum = tail + prev
Next i
MsgBox (Sum)
End Sub
Sub Sum()
Dim i, total
i = 0
total = 0
While (i <= ActiveCell.Value)
total = total + i
i = i + 1
Wend
MsgBox (total)
End Sub