Hi all,

I am relatively new to VBA but I have typically been able to spot my errors based on google and forum searches. This time, however, I cannot figure out what I am doing incorrectly and this piece of code is important for me to continue.

The following is the code:

[VBA]

If Cells(((numStats + 2) * X) + 5 + Y, 4).Value = "Annual GLWB Payout" Then

'MsgBox Cells(2, 150) & " + " & issueAge(X) & " = " & Cells(2, 150) + issueAge(X) & " > " & annuitizationAge(X)

For z = 5 To 304

Cells(((numStats + 2) * X) + 5 + Y, z).NumberFormat = "$0,000"

'Cells(((numStats + 2) * X) + 5 + Y, z).Value = Cells(2, z).Value + issueAge(X)

'Cells(((numStats + 2) * X) + 5 + Y + 1, z).Value = annuitizationAge(X)

'Cells(((numStats + 2) * X) + 5 + Y + 2, z).Value = (Cells(2, z).Value + issueAge(X) < annuitizationAge(X))

If (Cells(2, z).Value + issueAge(X)) < annuitizationAge(X) Then

Cells(((numStats + 2) * X) + 5 + Y, z).Value = 0

Else

Cells(((numStats + 2) * X) + 5 + Y, z).Value = Cells(((numStats + 2) * X) + 5 + Y - 1, z).Value * lwp(X)

End If

Next z

End If

[/VBA]

Sorry if my formatting is incorrect, this is my first time posting. The commented cells were done as a test.

issueAge(X) = (60, 51) and annuitizationAge(X) = (71, 57).

The z variable ranges over months and so Cells(2,z) tracks the years so, for example, after 12 years, Cells(2,149) + issueAge(0) should return > annuitizationAge(0) but it does not.

If I replace either issueAge or annAge with their values it returns correctly, but I need it to work for all X's.

Added extra detail in case it's necessary. Do you guys know why this is not working? Thanks!!