+ Reply to Thread
Results 1 to 17 of 17

Adding to dropdown list by typing (Excel 2007)

  1. #1
    Registered User
    Join Date
    07-17-2012
    Location
    Nova Scotia
    MS-Off Ver
    Excel 2007
    Posts
    21

    Question Adding to dropdown list by typing (Excel 2007)

    Hello,

    I am using Excel 2007 and I have a dropdown menu that autopopulates a field next to it. So, I can select someone's name from the menu and then their phone number appears in the cell next to it. I would like to have it so if the name isn't in the list, the user can type it into the blank, and then type the phone number into the next cell (which usually autopopulates). Then the new name would be part of the dropdown menu, and the correct phone number will autopopulate. I want to do this to make it as easy as possible for the people using the form to add names/numbers if needed. Is this possible? If not, do you have any other suggestions? The people using the file don't want to have to edit anything and need it to be as simple as possible to add new things.

    I'm pretty comfortable with excel basics, but the intermediate/advanced stuff is still fairly new to me!

    Thanks!

  2. #2
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Adding to dropdown list by typing (Excel 2007)

    Well you could create a button to pop up a userform, that would allow them to input the data they want, that would in turn add the data to your overall list and populate in your dropdown list.
    Last edited by amotto11; 07-17-2012 at 01:50 PM.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Adding to dropdown list by typing (Excel 2007)

    You would over write the formula for the phone number and if you use Data Validation you would not be able to write something not in the list
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Adding to dropdown list by typing (Excel 2007)

    Try this,

    You may be able to make it fit what you would like, if you cannot, i will help if you attach your workbook.

    Let me know if this will work
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-17-2012
    Location
    Nova Scotia
    MS-Off Ver
    Excel 2007
    Posts
    21

    Talking Re: Adding to dropdown list by typing (Excel 2007)

    Thanks a lot! I'm trying to make a userform now (my first time), but unfortunately I'm a little dumb at this stuff right now. The list I want to add to is in a worksheet called "Input Sheet" and the name list is G6 to G16, and the phone number list is H6 to H16. The first time the userform is used to add data I want the value to be added at the end of this list (G17 and H17). All I can find is how to have it populate the next blank row in a worksheet and I'm not sure how to edit it to work for me. I know I could just add a new worksheet, but I would rather not if I can avoid it. I followed most of these steps: http://www.contextures.com/xlUserForm01.html

    and I named the text boxes accname and accnum. Sorry if I'm not even close to being on the right track!

    Edit: I just saw what amotto11 posted, going to take a look now. Thanks again!

  6. #6
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Adding to dropdown list by typing (Excel 2007)

    the only thing you may have to change is the vlookup formula in the phone number, and the code that tells what sheet to look for in the userform since your sheet name is not sheet1. As long as there is nothing else on this page this should work because it looks for the last row that is empty to place the new name and number, so if there is data below in any column then the code will not work as you would like and your list will have a lot of blank spaces in it. you can adapt for this, if you just change the first line in my code to only look in the column that you would like to add the value too.

  7. #7
    Registered User
    Join Date
    07-17-2012
    Location
    Nova Scotia
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Adding to dropdown list by typing (Excel 2007)

    Ok, I got it so it adds the data to the correct columns, but it's adding it way further down the list than it should be. It is adding it to line 50 instead of line 17. There is no data in line 17 on, so I'm not sure what's happening. Here is the code I'm using (only slightly edited, I changed the name of my text boxes instead of changing the code you gave me):


    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-17-2012
    Location
    Nova Scotia
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Adding to dropdown list by typing (Excel 2007)

    Ah of course. I have other columns in my "Input Sheet", so it is putting the new data at the bottom of that, leaving blanks. I suppose I could rework the data so each thing is on a separate sheet. You mentioned that I could get around this by changing ther first line.. I'm pretty new at this, so how should I change it?

  9. #9
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Adding to dropdown list by typing (Excel 2007)

    Okay,

    All you need to do is in an empty cell put the formula, say Q2

    =CountA(G2:G65000)+2

    The plus 2 is because your starting in Q2 and you want to know where to put the next line.

    Then in your VBA code change your lRow line to say
    Please Login or Register  to view this content.
    If you wanted to, you could then change the color of the cell Q2 to be clear, so the user would have no idea it is there, or you could lock and protect the worksheet, or just hide the column that the formula is in.
    This should work, but let me know if you have other issues.
    Last edited by amotto11; 07-17-2012 at 03:57 PM.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Adding to dropdown list by typing (Excel 2007)

    To find the next empty cell in Column G just use

    Please Login or Register  to view this content.
    Why bother putting an unnecessary formula in a cell?

  11. #11
    Registered User
    Join Date
    07-17-2012
    Location
    Nova Scotia
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Adding to dropdown list by typing (Excel 2007)

    Thanks! It worked just like it's supposed to, I just have one problem that I didn't anticipate. When I select a name, the number that populates isn't correct. I believe because the list isn't in alphabetical order. Is there a way to have the list automatically sort, or a way I can make the dropdown menu read the list how I want? I'm also a bit confused on how to make the menu ignore the blanks at the bottom of the list (or have it just adjust the range so blanks aren't included... Whatever is easier). Thanks for all the help, and sorry for being a pain. I did look up how to do this, but was a little confused by what I was finding.

  12. #12
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Adding to dropdown list by typing (Excel 2007)

    For your first question. It shouldn't matter if the list is in alphabetical form or not. It is just a vlookup that is looking up the value. Do you have two names that are the same. The vlookup would only look at the first value. Otherwise there shouldn't be a problem with the correct number populating. Could you give me an example or something more that i could have to see what your problem is. I will try to fix the problem of blanks in the dropdown.

    ---------- Post added at 09:02 AM ---------- Previous post was at 08:40 AM ----------

    KJL,

    Is the only time that the list gets larger when the person imputs a new name? I may have a solution if that is the case. you can let them enter a name in then make the list get longer. This would be the new code with RoyUK's solution in it. the end of this code will build the data validation box and populate it. when you add new names it will change the length of the data validation, but only when you add new names through the button. If you were going to start just by placing names on the page, all you would have to do is make your last name and number with the button and it will make your data validation and set it good to go. Remember my code is not using your cells, so just change the references and you should be good to go.

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    07-17-2012
    Location
    Nova Scotia
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Adding to dropdown list by typing (Excel 2007)

    I've attached the file so you can see what's happening. The userform I'm trying to get to work is "Accomodations" (or "Lodging"). As you can see it works fine until you add new accomodations, then the phone numbers and names don't match (unless I alphabetize the list). That's the main problem.

    It's a bit of a mess.. The data is all in "Input Sheet" but the dropdown menus point to the main sheet (you'll see what I mean). I'm not sure why it was set up like that originally, but if I need to change it to point to the Input Sheet, I can do that. The font color of the extra data on the main sheet is normally white, so it's not a huge deal. I took the data out that wasn't needed to show the problem, so it looks a bit strange.

    Thanks again, you've been a lot of help.
    Last edited by KJL; 07-18-2012 at 11:14 AM. Reason: deleted attachment

  14. #14
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Adding to dropdown list by typing (Excel 2007)

    KJL,

    I am sorry, but i really can't make heads or tails of what you are saying is the problem.

    I see that you are using my form to create new lodging, and i am using your dropdowns on the first page and i see that the phone numbers are coming in correctly. Could you give me more of an understanding of what you are doing and what the problem is. Thanks, and sorry i was not able to understand your last post very well.

  15. #15
    Registered User
    Join Date
    07-17-2012
    Location
    Nova Scotia
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Adding to dropdown list by typing (Excel 2007)

    Woops, that probably partially because I attached the wrong version of my file! My rambling probably doesn't help either haha.. I attached the right one now. Sorry about the confusion.

    Example of the problem:
    Say I add a new accomodation called "GGGGGGG" with phone number 555-555-5555. When I select GGGGGG under proposed lodging, it gives the phone number for the Delta hotel instead of 555-555-5555. If I alphabetize the list, it works correctly.
    Last edited by KJL; 07-25-2012 at 10:10 AM.

  16. #16
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Adding to dropdown list by typing (Excel 2007)

    KJL,

    You need to use my vlookup formula that i wrote for you in my first example. At the end of the formula you will notice that i have put FALSE, this insures that it will look for an "exact" match, and it will only search down to as many rows as you have. what it is doing right now most likely is looking for a match that looks sort of like it, so when it finds one that is similar, or it it hinks is similar it stops there and puts that number. Also you don't have to put the values on the page that you are working with, you can reference the Input Sheet in your data validation. I would also use my data validation formula at the end of all of your userform codes. this way it will not show all of your 0's, nor any blanks. Hope this helps you. If you get stuck i can do this for you. I am just afraid i may miss something you are trying to accomplish, plus it is always a good learning tool. Let me know if this works and helps you out.
    Last edited by amotto11; 07-18-2012 at 11:48 AM.

  17. #17
    Registered User
    Join Date
    07-17-2012
    Location
    Nova Scotia
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Adding to dropdown list by typing (Excel 2007)

    Perfect, I go everything working exactly how I wanted. Thanks for all of your help, I learned a lot from this!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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