In diesem Beispiel wird die Tabellenfunktion RMZ (Pmt in VBA) zur Berechnung der Zahlungen für ein Hypothekendarlehen verwendet. Beachten Sie, dass dabei nicht die InputBox-Funktion, sondern die InputBox-Methode verwendet wird, so dass eine Typenüberprüfung durch die Methode möglich ist. Die Static-Anweisungen sorgen dafür, dass in Visual Basic die Werte der drei Variablen erhalten bleiben und beim nächsten Ausführen des Programms als Standardwerte angezeigt werden.
Static loanAmt Static loanInt Static loanTerm loanAmt = Application.InputBox _ (Prompt:="Loan amount (100,000 for example)", _ Default:=loanAmt, Type:=1) loanInt = Application.InputBox _ (Prompt:="Annual interest rate (8.75 for example)", _ Default:=loanInt, Type:=1) loanTerm = Application.InputBox _ (Prompt:="Term in years (30 for example)", _ Default:=loanTerm, Type:=1) payment = Application.WorksheetFunction _ .Pmt(loanInt / 1200, loanTerm * 12, loanAmt) MsgBox "Monthly payment is " & Format(payment, "Currency")