+ Reply to Thread
Results 1 to 4 of 4

Trying to determine if a list box item is selected

  1. #1
    Registered User
    Join Date
    09-21-2012
    Location
    Minnesota, US
    MS-Off Ver
    Excel 2010
    Posts
    15

    Trying to determine if a list box item is selected

    Hi All,

    I have a simple userform and am struggling to find a way to make sure something is selected in the list box before the data is transferred to a table.

    Here is one of the various things I have tried. For some reason the SelectedItem method isn't found and I get "method or data member not found". I have double checked this is indeed a list box, and the name is correct.

    Please Login or Register  to view this content.
    I also tried the SelectedItem = -1 version of the above.

    Here is another one I tried, but it doesn't allow the Exit Sub to work properly

    Please Login or Register  to view this content.
    Any help is greatly appreciated, Thank you.

  2. #2
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Trying to determine if a list box item is selected

    You mention "listbox" but your code addresses "Comboboxes" ??

  3. #3
    Registered User
    Join Date
    09-21-2012
    Location
    Minnesota, US
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Trying to determine if a list box item is selected

    That's referencing a combobox to determine if the rest is required. The ModelListBox selection is the second step, and what I need.

    If the combobox has anything other than Loegring then a model must be selected from the list box.

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Trying to determine if a list box item is selected

    Hi,

    Is it a multiselect listbox? If not, all you need to do is test if its ListIndex property is greater than -1; if it is multiselect, then you need to loop as in your example, but your Exit Sub will always run the way you had it written.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

+ 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] Active X drop down list - always return to the item in the list that was selected.
    By Aland2929 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-14-2017, 09:41 AM
  2. Combobox: How to determine the location of the selected item if combobox has rowsource
    By ahsanzafar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2012, 03:24 PM
  3. Determine Selected Item in a (Userform’s) ComboBox
    By StevenM in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-07-2012, 09:07 AM
  4. How can I determine what the range is of a selected list box
    By rschnarr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-11-2011, 04:37 PM
  5. Replies: 3
    Last Post: 01-24-2011, 12:48 PM
  6. Selected combobox item to determine variable value
    By dems in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-22-2010, 11:40 PM
  7. Determine which item in a list box was chosen?
    By max3732 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2010, 01:41 AM

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