+ Reply to Thread
Results 1 to 27 of 27

ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

  1. #1
    Registered User
    Join Date
    05-06-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    2013
    Posts
    41

    ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    On a UserForm I have a very small ComboBox populated with a very short list of numbers.
    I don't want a DropDown arrow because it takes up the whole box. I just want the list to show when the ComboBox is entered.

    So I have the ShowDropButtonWhen property set to Never and in the ComboBox Enter event I have "ComboBox1.DropDown".

    It works fine when I tab through the controls, but if the ComboBox is selected with the mouse the DropDown arrow appears. That's not Never.
    (It's the same thing with or without the Enter event.)

    What am I doing wrong? How can I make it so the drop down button never shows?

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    Set ListRows one greater than number of items in list.

    probably misunderstood you
    Last edited by torachan; 09-24-2019 at 11:06 AM.

  3. #3
    Registered User
    Join Date
    05-06-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    2013
    Posts
    41

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    I tried your suggestion torachan, but it made no difference.

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    That works for me, do you have any other event code for that combo?

  5. #5
    Registered User
    Join Date
    05-06-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    2013
    Posts
    41

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    There's no other event code for that combobox. I made a Userform with nothing but what I needed to test this situation.

    Do you mean torachan's solution works for you? Or that when you set the ShowDropButtonWhen to Never the dropdown arrow doesn't show when you select the combobox with the mouse?

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    I mean if I set the ShowDropButtonWhen to Never (option 0) i don't see the button, no matter how I select the combo.

  7. #7
    Registered User
    Join Date
    05-06-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    2013
    Posts
    41

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    It's not working for me. I've tried it out on two computers, same thing. (Both have Excel 2013 installed.)

    I've uploaded my test file for anyone who's interested in taking a look? I'd appreciate any help with this.
    Attached Files Attached Files
    Last edited by melpa; 09-24-2019 at 12:39 PM.

  8. #8
    Registered User
    Join Date
    05-06-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    2013
    Posts
    41

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    Since uploading the file I've noticed that if the combobox isn't populated the dropdown arrow never shows - which is the desired case.
    Maybe there's no arrow because there's no list, but it got me wondering if the problem is in the way I'm populating the combobox.
    Currently I'm using " ComboBox1.List = Array(1, 2, 3, 4) " in the Initialize event of the userform.
    So I tried using the AddItem method instead, but that doesn't make any difference either.
    Does anyone have any ideas?

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    Change the Style property to 0 from 2

  10. #10
    Registered User
    Join Date
    05-06-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    2013
    Posts
    41

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    The style is already set to 2 - fmStyleDropDownList.

  11. #11
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    You need to change it to 0.

  12. #12
    Registered User
    Join Date
    05-06-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    2013
    Posts
    41

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    Sorry, I misread your post. I'll get back to you...

  13. #13
    Registered User
    Join Date
    05-06-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    2013
    Posts
    41

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    Progress! Thanks Fluff.
    Unfortunately however, now the user can type anything at all into the combobox and I want to restrict values entered to only those provided in the dropdown - which is why I had it set to 2.
    Is there a way to have both restricted input AND no dropdown arrow?

  14. #14
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    Appears not. Does does seem as though those two options are mutually exclusive for some reason.

  15. #15
    Registered User
    Join Date
    11-04-2014
    Location
    Portugal
    MS-Off Ver
    XL2013/XL365
    Posts
    88

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    This restrict values entered

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    05-06-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    2013
    Posts
    41

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    Fantastic. Thanks JCabral.

    Now the user can ONLY select values from the dropdown list.

    I haven't learnt about KeyAscii yet, but a quick google search gives me the impression it restricts the use of the keyboard.
    Which leads me to my next question:
    My list only has four values: 5, 10, 50 and 100.
    Are you able to tell me how to restrict the keys available to 1, 5 and 0?
    I would like the users to retain the ability to type in the values if they choose.
    Last edited by melpa; 09-24-2019 at 03:10 PM.

  17. #17
    Registered User
    Join Date
    11-04-2014
    Location
    Portugal
    MS-Off Ver
    XL2013/XL365
    Posts
    88

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    Hi

    I'm not a VBA connoisseur, but try something like the code below

    Please Login or Register  to view this content.

  18. #18
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    Try the attached, all the settings have been done in the UserForm initialization code.
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    05-06-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    2013
    Posts
    41

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    Thanks JCabral, your solution works a little bit. With your code 1, 5 and 0 are the only keys that the combobox responds to, but the effect of all of them is to select the first number in the list. I can’t type in 10, 50 or 100.
    Unfortunately this solution is no longer relevant anyway because I discovered that when I change the Style property to “ 0 – fmStyleDropDownCombo “ even though it’s true that the Drop Button doesn't show when the ComboBox is selected with the mouse, it takes away both of the other requirements: ie. it allows anything to be typed into the combobox and it also turns out that the list doesn't show on entry anymore – ( “ComboBox1.DropDown” doesn’t appear to work).

    Thanks torachan, but your attachment isn't working for me either. I can only enter values from the list, which is one requirement, but the list doesn't drop down on entry and the button appears when the combobox when it is selected with the mouse.

    So thanks for everyone's input so far, but I still haven't found the solution.

  20. #20
    Registered User
    Join Date
    05-06-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    2013
    Posts
    41

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    Hi all.

    My dilemma is still not solved, but I can articulate it more clearly now after trying out the various solutions that have been offered to me in this thread.

    My aim is to have a ComboBox on a UserForm that:
    a) Never shows the drop button.
    b) Prohibits values other than those in the list supplied.
    c) Shows its list on entry (whether tabbed to or selected with cursor / mouse).

    I thought this should be straight forward
    a) Set ShowDropButtonWhen property to: 2 – fmShowDropButtonWhenNever
    b) Set Style property to: 2 – fmStyleDropDownList (to restrict values entered)
    c) Put "ComboBox1.DropDown" in the ComboBox1 Enter event

    However this doesn't work. When the ComboBox is selected with the mouse the Drop Button shows.


    Given that ComboBox properties are right there in plain sight (ie. standard issue - I don’t have to write code to set them), I can't understand why when I select one property it appears to cancel out the other. Surely the dropdown button should NEVER show.
    In fact, on the official Microsoft website the description for 0-fmShowButtonWhenNever is “Do not show the drop-down button under any circumstances.”
    (https://docs.microsoft.com/en-us/off...nwhen-property).

    So, I’m at a loss. I’ve uploaded an updated file illustrating the problem with the continued hope that my dilemma can be solved.
    Attached Files Attached Files

  21. #21
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    If you set the MatchRequired property to True, they won't be allowed to enter something that isn't in the list.
    Rory

  22. #22
    Registered User
    Join Date
    05-06-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    2013
    Posts
    41

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    Hi rorya.
    I think that's only relevant if I use the DropDownCombo style, which is no good in this case because it doesn't show the list on entry.
    Also, when I tried that out on the file I uploaded it made the DropDownCombo style combobox virtually unusable.

  23. #23
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    A simple alternative is to validate the entered data by checking that the Listindex property is not -1 (i.e. the entry matches something in the list).

  24. #24
    Registered User
    Join Date
    05-06-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    2013
    Posts
    41

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    The DropDownCombo style – being the one that needs code to restrict entries – doesn’t automatically show its list when entered even though I have “"ComboBox.DropDown" in the Enter event.

    I’m looking for a solution that satisfies all three criteria: Never shows the button, Restricts user entries, Drops list automatically on entry.

  25. #25
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    I'd fake it with a listbox and a textbox, just make the listbox visible when the textbox is entered and set the focus to the listbox. This essentially makes the textbox read-only and its value is set by the listbox

  26. #26
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    It drops down on entry for me. For only 4 values, you could just use a textbox and spinbutton, which would also make it easier if the user needs to change an entry.

  27. #27
    Registered User
    Join Date
    05-06-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    2013
    Posts
    41

    Re: ComboBox DropDown Button: ShowDropButtonWhenNever - Button still shows.

    Hi rorya. It's strange that it drops down for you, but not for you. I'll try out you alternative suggestion. Thank you.
    Thanks for your suggestion too, Kyle. I'll also explore your idea.

+ 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. vba userform Populate combobox when press the dropdown button
    By Ankers in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2017, 03:30 AM
  2. Replies: 1
    Last Post: 02-27-2017, 09:17 AM
  3. [SOLVED] Form - select button & retrieve button name or button's caption
    By lexusap in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-27-2016, 12:28 AM
  4. Make a button that rolls a die and shows it in a popup
    By zerocyber in forum Excel General
    Replies: 6
    Last Post: 06-09-2014, 07:47 AM
  5. ComboBox.DropDown ONLY SHOWS FIRST ITEM with TINY SCROLLBAR
    By Guido Meng in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-25-2013, 03:15 PM
  6. Combobox Dropdown List only shows first Item
    By Guido Meng in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-20-2013, 09:49 PM
  7. Option Button that shows/hide certain cells
    By DoubLeA in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 03:31 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