+ Reply to Thread
Results 1 to 7 of 7

If function to test drop down menu selection

  1. #1
    Registered User
    Join Date
    06-10-2014
    Posts
    2

    If function to test drop down menu selection

    I have what is, I hope, a simple question. But I can't seem to find the answer on the interwebs, so here I am. I am developing a spreadsheet at work that is very similar to one that I made at a previous job. I am using the same formula in each spread sheet, but the one I am developing now does not work, where the previous one works perfectly.

    I have a drop down menu created with data validation. Each possible selection is one or two letters of text, or the selection can be left blank. The drop down is cell A12, and an example of the if function that is used many times in this spreadsheet is as follows:

    =IF($A$12="L",1,0)

    In the previous spreadsheet, the function returns true only when the appropriate selection is made. In the latest version, it will return true if the appropriate selection is made, or if drop down selection is blank. I have been able to work around this with the following:

    =IF($A$12="",0,IF($A$12="L",1,0))

    It works, but is annoying, anybody know what I could be doing wrong here?

  2. #2
    Forum Expert
    Join Date
    03-28-2014
    Location
    Hyderabad,India
    MS-Off Ver
    Excel 2013
    Posts
    1,887

    Re: If function to test drop down menu selection

    Hi,

    Plz provide a sample book need to check the drop down , i.e data validation also as the if function is working fine .

    Punnam

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: If function to test drop down menu selection

    Hi and welcome to the forum

    =IF($A$12="L",1,0)

    In the previous spreadsheet, the function returns true only when the appropriate selection is made
    This should still be the case. I cannot see why that will return 0 (FALSE), if you have anything other than "L" in A12.

    Can you upload a small sample workbook for me to look at please?
    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: If function to test drop down menu selection

    One reason may be that your drop down list may contain leading or trailing spaces. Check the length of A12 and make sure it is 1.
    Or alternatively you can try

    Please Login or Register  to view this content.
    Last edited by sktneer; 06-11-2014 at 12:31 AM.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  5. #5
    Registered User
    Join Date
    06-10-2014
    Posts
    2

    Re: If function to test drop down menu selection

    Here are the two files, at least I think they're attached anyhow. I've highlighted the cells that are related to this formula. Let me know if you have any questions. I tried adding the trim function, and that didn't do it. Let me know if you can figure this one out. Like I was saying, I found a work around, but I'm just curious what I'm doing wrong here.

    Thanks
    Attached Files Attached Files

  6. #6
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: If function to test drop down menu selection

    On both of your sheets, the formula is working fine. I don't see any issue with the formula.
    Make sure that Calculation Options is set to Automatic to see if this is the issue.

  7. #7
    Registered User
    Join Date
    06-10-2014
    Posts
    2

    Re: If function to test drop down menu selection

    Please take another look. I've uploaded these again with some values filled in. When no option is selected in the yellow cell, the green cell returns 0 in the "old" spreadsheet, but returns 1 in the "CTA" spreadsheet (at least on my machine).

    Calculation is set to automatic in both.
    Attached Files Attached Files

+ 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. Replies: 3
    Last Post: 07-31-2013, 11:53 AM
  2. Replies: 1
    Last Post: 03-27-2013, 07:04 AM
  3. Replies: 3
    Last Post: 01-31-2013, 06:22 PM
  4. Drop down menu-how i can get detail after selection
    By adeelkhan007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-21-2011, 09:43 AM
  5. Drop-Down Menu Selection
    By moncureww in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-28-2008, 01:15 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