I am just starting to learn VBA. I am using the following code but am getting an error when I try to run Sub test:
Compile Error: Variable not defined
Can you help me figure out what is wrong?
Private Sub CommandButton1_Click()
Dim dblPrincipalAmt As Double
Dim dblInterestRate As Double
Dim intYears As Integer
Dim dblInterestAmt As Double
If Not IsNumeric(txtPrincipalAmt) Then
MsgBox "INVALID PRINCIPAL AMOUNT"
Exit Sub
End If
If Not IsNumeric(txtInterestRate) Then
MsgBox "INVALID INTEREST RATE"
Exit Sub
End If
If Not IsNumeric(txtYears) Then
MsgBox "INVALID YEAR"
Exit Sub
End If
Let dblPrincipalAmt = txtPrincipalAmt
Let dblInterestRate = txtInterestRate
Let intYears = txtYears
Let dblInterestAmt = dblPrincipalAmt * dblInterestRate * intYears
Let TBIA = dblInterestAmt
End Sub
I am trying to find the error so that I can fix it right away.
Letis deprecated.