Closed Thread
Results 1 to 3 of 3

Custom formula to check entered number against conditions which increses in 5 steps

  1. #1
    Registered User
    Join Date
    10-02-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    10

    Custom formula to check entered number against conditions which increses in 5 steps

    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]
    Attached Files Attached Files

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Custom formula to check entered number against conditions which increses in 5 ste

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Custom formula to check entered number against conditions which increses in 5 ste

    You are in violation of at least 4 Excel Forum Rules. Please read them and amend all of your created threads accordingly. You are new so I won't ban you but if you do not fix all of your threads, I will be forced to ban you. For now, I am going to mark this thread as closed until you take care of your previous threads.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1