+ Reply to Thread
Results 1 to 6 of 6

If else statement help

  1. #1
    Registered User
    Join Date
    08-30-2016
    Location
    England
    MS-Off Ver
    2013
    Posts
    2

    If else statement help

    Hello. Im having some problems wrighting this code into excel.
    I have a range of data between 1 and 100,000. im looking for numbers above 20,000 to be in the Good section and below 20,00 to be in the poor section. Additionally i want all numbers below 5,000 to be discounted and the "Good" "Poor" box to be left blank.
    I can wright this in code as below:

    If 5000<B2>20000:
    B3 = "Poor"
    elif B2>20000:
    B3 = "Good"
    elif B2< 5000:
    B3 = ""
    else:
    B3 = "Unknown"

    problem is i cant find any elif functions in excel, it all seems to be "if true then / if flase then" whereas i just want if "true then"

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If else statement help

    Quote Originally Posted by AceScottie View Post
    numbers above 20,000 to be in the Good section and below 20,00 to be in the poor section.
    And what if the number IS 20,000?

    This happens quite often.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: If else statement help

    make a VLookup table

    C D
    0 blanc
    5000 poor
    20000 good

    after that

    b1=vlookup(a1,$c$1:$d$3,2,1)
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: If else statement help

    Try this
    Enter formula in C2 and copy down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    v B C
    1
    2 4000
    3 20000 Good
    4 30000 Good
    5 4000
    6 5899 Poor
    7 19999 Poor
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  5. #5
    Registered User
    Join Date
    08-30-2016
    Location
    England
    MS-Off Ver
    2013
    Posts
    2

    Re: If else statement help

    Thanks very much, using Lookup works perfectly for this information set

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If else statement help

    If there are only 3 variables you can use an IF function...

    =IF(B2>=20000,"Good",IF(B2>=5000,"Poor",""))

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] i have an if then statement that works, how to make it work as a with or case statement
    By dmcgov in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-03-2016, 03:34 PM
  2. [SOLVED] If statement to select data - nested statement - assistance
    By petitesouris in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-29-2015, 09:55 PM
  3. compile error expected line number statement end statement
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2014, 10:12 AM
  4. VBA Compile Error : line number or label or statement or end of statement
    By excellearner121 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2013, 06:41 PM
  5. Replies: 4
    Last Post: 06-01-2012, 10:05 AM
  6. Replies: 4
    Last Post: 05-16-2012, 05:33 PM
  7. [SOLVED] Utilize a Select Case Statement in Target Intersect Statement
    By max57 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2009, 08:55 PM

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