+ Reply to Thread
Results 1 to 3 of 3

if anything in listbox select first item, if listbox empty do nothing (listbox in userform

  1. #1
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2013
    Posts
    116

    if anything in listbox select first item, if listbox empty do nothing (listbox in userform

    Hello, all,

    I have a listbox "Yval_box" that is usually populated with information. When the userform containing Yval_box opens I have set the 1st item in the listbox to be selected with:

    Please Login or Register  to view this content.
    What I want is the above code to run only if items appear in the list box.

    Thanks!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,603

    Re: if anything in listbox select first item, if listbox empty do nothing (listbox in user

    Perhaps.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2013
    Posts
    116

    Re: if anything in listbox select first item, if listbox empty do nothing (listbox in user

    Thank you, Norie!

    .listcount was what I couldn't figure out.


    For posterity, I updated Yval.listcount to Yval_box.listcount to get this to work.

+ 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. Is it possible to pre-select an item in a ListBox in a Userform?
    By bananajelly in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-07-2014, 02:14 PM
  2. Select one item from a listbox disables another listbox
    By EagleInsight in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-22-2014, 09:53 PM
  3. Listbox to Listbox, no duplicates & submitting same UserForm data for each Listbox entry.
    By jamieswift1977 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2012, 12:18 PM
  4. [SOLVED] Can one use a Listbox on UserForm without allowing the user to select an item?
    By StevenM in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-26-2012, 05:44 PM
  5. Multi select Listbox Items selection based on other Listbox item selection.
    By srinivassathi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-20-2011, 05:53 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