Verilen sayı ile ilgili faktöriyel hesabı yapan VBA kodudur.
Option Explicit
Sub FaktoriyelHesapla()
Dim i As Long
Dim sayi As Long
Dim faktoriyelSonuc As Double
faktoriyelSonuc = 1
sayi = InputBox("Faktöriyeli hesaplanacak sayıyı giriniz:")
For i = 1 To sayi
faktoriyelSonuc = faktoriyelSonuc * i
Next
MsgBox sayi & "! = " & faktoriyelSonuc
End Sub