Hi,
I am trying to calculate a formula using VBA. I want to check the entered no. in a cell and then check it if it is less than 20k result shouls be 1, if it is less than 80k result should be 2, if it is less than 150k result should be 3, if it is less than 250k result should be 4, if number is less than 500k result should be 5, if number is less than 520k result should be 6, if number is less than 580k then result should be 7 and so on, up to 1600k.
The code that I have written is given below but it does not work. Please find attached the sample sheet.
[Private Sub OAM(PH As Long)
Dim i As variable
If A1 > 0 Then
For i = 1 To 161 Step 1
If PH <= 20000 Then
OAM = i
Else
If PH <= 80000 Then
OAM = i + 1
Else
If PH <= 150000 Then
OAM = i + 2
Else
If PH <= 250000 Then
OAM = i + 3
Else
If PH <= 500000 Then
OAM = i + 4
End If
End If
End If
End If
End If
Next i
Else: OAM = 0
End If
End Sub]
Bookmarks