Sorry, that is what you get for copying a single line.
My thoughts were ......
Once you find the correct A & whatever then you set and exit the loop, else, yes, you just override the values.
Once you have exited the loop, those values displayed are the ones used.?
As mentioned not tested as it was written in Notepad.?
Here is my attempt now I put it into Access
Code:
Sub TestALoop(EmpRank As String)
Dim i As Integer, iSalary As Integer, IMeal As Integer, iLeave As Integer
Dim EmpSalary As Integer, EmpMealAllowance As Integer, EmpLeaveAllowance As Integer
iSalary = 50
IMeal = 20
iLeave = 80
For i = 1 To 15
If EmpRank = "A" & i Then
EmpSalary = 1000 + (iSalary * (i - 1))
EmpMealAllowance = 800 + (IMeal * (i - 1))
EmpLeaveAllowance = 500 + (iLeave * (i - 1))
Exit For
End If
Next
Debug.Print "A" & i & " " & EmpSalary & " " & EmpMealAllowance & " " & EmpLeaveAllowance
End Sub
Debug Output
Code:
A3 1100 840 660
A15 1700 1080 1620
A7 1300 920 980
At the end of the day, I was trying to show the concept/logic?
I would probably have used a table, but that opens another can of worms for a new poster.