+ Reply to Thread
Results 1 to 19 of 19

removing blanks and duplicates in drop down list (with attached workbook)

  1. #1
    Registered User
    Join Date
    09-06-2012
    Location
    Timbaktu
    MS-Off Ver
    Excel 2010
    Posts
    12

    removing blanks and duplicates in drop down list (with attached workbook)

    Please view attached workbook.

    Each cell in column B has a drop down menu. This drop down menu shows duplicates and blanks.
    I know very little about excel, but the A column will have hundreds of animals and I need to tag each animal with its family without using a predetermined list. Imagine it was a test where the student had to correctly input the family of the animal (not multiple choice but he has to come up with the answers himself but he would like the list to grow as he progresses so he doesn't have to retype the same thing repeatedly) but did not want to have duplicates or blanks in the drop down list. Thanks.


    I have also posted on another website in hopes of getting an quick answer.

    http://www.mrexcel.com/forum/excel-q...down-list.html
    Attached Files Attached Files
    Last edited by zebrasam; 09-06-2012 at 10:28 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    04-03-2012
    Location
    East Sussex, UK
    MS-Off Ver
    Excel 2003:2010
    Posts
    893

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    What do you mean by "without using a predetermined list"?
    I'm a bit confused as to what you're trying to do...
    If I've been of help, please hit the star

  3. #3
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    Zebrasam,

    Are you willing to use towards your solution? When I look at the validation that you currently have set, it seems to refer to information already entered into column B. So, as new items are entered, they become part of the list. Is that what you would LIKE to happen? If so, try the following suggestion, which requires some simple VBA.

    First, delete all of the current validation that you have in Column B.
    Next, right click on the Sheet tab (where it says Sheet1), and choose View Code.
    Next, enter the following code:
    Please Login or Register  to view this content.
    Now, whenever you select a cell in column B, a drop down with all previously entered items will automatically pop open.

    Does this work for you?

  4. #4
    Registered User
    Join Date
    09-06-2012
    Location
    Timbaktu
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    This does work for me thanks! On my real spreadsheet however (and not this fictional one) I have multiple columns I would like to apply this to. Also the top row is frozen so I want to exclude the top row from the code.

  5. #5
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    Can you be more specific about which columns this code should work with?

  6. #6
    Registered User
    Join Date
    09-06-2012
    Location
    Timbaktu
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    columns d, e, f, g, h, j, k (not a, b, c and i)

  7. #7
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    I revised the code to only work on the requested columns, and to also ignore row 1

    Does this work?

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-06-2012
    Location
    Timbaktu
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    It all works except the first row is not being ignored.

  9. #9
    Registered User
    Join Date
    09-06-2012
    Location
    Timbaktu
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    However if it is too much trouble it is still functional with the code as is. However, if the solution is easy let me know

  10. #10
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    The code SHOULD ignore the first row as it sits. Is the first row of your data in Row 1 in Excel (ie, does it start with Cells A1, B1, etc)?

    If not, we have to change the third line of code (starts with "If Target.Row = 1....)

    Change the 1 to whichever is the first row of your data.

    If this still doesnt work, can you post a sample of your workbook and I'll try and determine the cause

  11. #11
    Registered User
    Join Date
    09-06-2012
    Location
    Timbaktu
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    Filtering is enabled in all the cells of the 1st row. When I turned off filtering the problem was solved. However I need filtering enabled.

    Also, the fonts in the drop down box are too large and the drop down boxes are a bit narrow. Anyway I can change this?

  12. #12
    Registered User
    Join Date
    09-06-2012
    Location
    Timbaktu
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    Oops turning off filtering makes no difference...I'm going to check again

  13. #13
    Registered User
    Join Date
    09-06-2012
    Location
    Timbaktu
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    Hi I have uploaded a file that I tested with your code. It seems that if the contents of the b column or the c column are deleted then the problem with the first row appearing in the drop down lists disappears. I have uploaded the excel spreadsheet without your code. If you apply your code to it perhaps you will see the problem.
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    I think I understand the problem.

    With this code, we are using Excel's built-in "Pick from List" feature to create data lists for the user. Unfortunately, to the best of my knowledge, we cannot change the font within these drop down boxes.

    Also, with this built in feature, Excel picks items that it believe are part of the list. If you don't want the first row included in the lists, Excel has to recognize that Row 1 is a header row. In order to do so, there should be a heading in row 1 of each column that has corresponding data. I tested the file by including headers in cell B1 and C1, then the items in rows 1 were no longer added to the drop down.

    If for presentation purposes you do NOT want any data in Cells B1 or C1, you can simply put in a single space and that should do the trick.

    Let me know if it helps

  15. #15
    Registered User
    Join Date
    09-06-2012
    Location
    Timbaktu
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    Thanks that solved the problem.
    If we cannot change the font size is there any possibility of making the drop down lists wider?

  16. #16
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    I believe the drop down lists are as wide as the cell itself. If you expand the column, the drop down will also expand

  17. #17
    Registered User
    Join Date
    09-06-2012
    Location
    Timbaktu
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    Yes you are right about the width. I think it is now working perfectly. Thanks so much for your help with this!

    Take Care

    Sam

  18. #18
    Registered User
    Join Date
    09-06-2012
    Location
    Timbaktu
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    Hi,

    I ran into a problem. If you look at the "test" spreadsheet I attached previously you will notice that even if all the headings are filled in the first row, the drop down list only works for the 3rd row. If you don't fill in cells on the 3rd row and want to fill in cells on the 4th, 5th, 6th rows etc...nothing appears in the drop down list.

  19. #19
    Registered User
    Join Date
    09-06-2012
    Location
    Timbaktu
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: removing blanks and duplicates in drop down list (with attached workbook)

    What I have done is do a search and replace for all the blank cells. I put a star like this * in each blank cell and that has solved the problem temporarily.

    It seems like your formula doesn't like blank cells.

    Is there anyway we could fix this?

+ Reply to 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