+ Reply to Thread
Results 1 to 6 of 6

Check if any ListBox items are selected?

  1. #1
    Forum Contributor
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    680

    Check if any ListBox items are selected?

    ListBox property: Allow multiple selection

    Is there a single line of code to check if a ListBox has any selected items? I think I know how to loop through the ListBox and check if each item is selected or not. But not sure if there is a quick way to check if ListBox has any selected items.

    Thanks.

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Check if any ListBox items are selected?

    Please Login or Register  to view this content.
    Test in attached workbook
    Attached Files Attached Files
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Contributor
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    680

    Re: Check if any ListBox items are selected?

    Quote Originally Posted by kev_ View Post
    Please Login or Register  to view this content.
    Test in attached workbook
    Thanks, that is also what I thought, but my question is: if there is a quick way to determine the result, rather than looping through each item.

    Anyway, I can loop through it.

  4. #4
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,157

    Re: Check if any ListBox items are selected?

    And another clone ... ... for one UserForm (UserForm1), one ListBox (ListBox1), two command buttons (1 and 2):
    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Check if any ListBox items are selected?

    Specificaly testing for nothing selected:
    Please Login or Register  to view this content.

    With a single-item-select listbox this works:
    Please Login or Register  to view this content.
    Last edited by kev_; 02-28-2018 at 02:12 PM.

  6. #6
    Forum Contributor
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    680

    Re: Check if any ListBox items are selected?

    Quote Originally Posted by kev_ View Post
    Please Login or Register  to view this content.
    Thanks, that is perfect.

+ 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. Listbox pre-selected items
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-30-2017, 12:16 AM
  2. Listbox Multiple Selected Items
    By rain4uu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-16-2014, 02:08 AM
  3. [SOLVED] Add Selected Items From One ListBox to Another ListBox on UserForm
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-27-2014, 06:53 PM
  4. Copy Selected items from multicolumn, multiselect listbox to another listbox
    By Willigb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-19-2013, 11:27 AM
  5. Transfer random listbox items to new listbox and then loop through selected items
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2013, 05:58 PM
  6. Check if 2 consecutive Form listbox items selected
    By Foreverlearning in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-24-2012, 07:55 PM
  7. [SOLVED] How to use selected items from Listbox
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-07-2006, 11:10 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